'BeautifulSoup - Is there a way to find starting from a specific row number?
I am using python and BeautifulSoup for making a discord bot I have my code:
URL = "https://www.mywebsite.com"
with requests.Session() as s:
r = s.post(URL)
soup = BeautifulSoup(r.content, 'html5lib')
firstresult = soup.find_all('p',attrs={"class" : "myclass"}, limit=6)
secondresult = soup.find_all('p',attrs={"class" : "myclass"})
'firstresult' finds the first 6 tags in the page. I want the 'secondresult' to find all the tags starting from 6 because i already have the first 6 in 'firstresult'
Solution 1:[1]
To access all tags from the 6th tag onward, since find_all() returns a list, you can use index slicing (zero index based):
secondresult = soup.find_all('p',attrs={"class" : "myclass"})[5:]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
