Answer the question
In order to leave comments, you need to log in
How to parse not the first link, but all links from the code?
The problem is this:
def bf_parse(base_url, headers):
session = requests.session()
request = session.get(base_url, headers=headers)
if request.status_code == 200:
soup = bs(request.content, 'html.parser')
divs = soup.find_all('div', attrs=('forum-user-name'))
for div in divs:
users = soup.find('div', {'class': 'forum-user-name'}).find('a').get('href')
print(users)
else:
print('ERROR')
bf_parse(base_url, headers)
Answer the question
In order to leave comments, you need to log in
It seems that the jamb in the logic is in this line
Here, the first matching div.forum-user-name is searched for on the entire page, but we need to search only in the block we are iterating over.
I can’t tell you exactly the solution, I don’t know the language
Probably something likeusers = div.find('a').get('href')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question