I'm learning scraping with Beautifulsoup and am using Stackoverflow's interesting questions section ("https://stackoverflow.com/?tab=interesting") for practice.
I want to extract hyperlinks for the top 5 questions that the user has tagged with 'java' AND that has at least one answer (ok if the answer has been accepted but not a requirement).
I've looked at the Beautifulsoup documentation, but I can't get it to come together.
Thanks for any help!
CODE:
from bs4 import BeautifulSoup
from urllib.request import urlopen
html = urlopen("https://stackoverflow.com/?tab=interesting")
content = html.read()
soup = BeautifulSoup(content)
soup.findAll('a',{'class':'question-hyperlink'}, href = True , limit=5) # question link
soup.findAll('div', {'class':'status answered'}, limit=5) # question answer
soup.findAll('a',{'class':'post-tag'}, rel ='tag' , text = 'java', limit=5) # question user tag
DESIRED OUTPUT (as hyperlinks):
https://stackoverflow.com/questions/number/first-question-to-meet-the-criteria
https://stackoverflow.com/questions/number/second-question-to-meet-the-criteria
https://stackoverflow.com/questions/number/third-question-to-meet-the-criteria
https://stackoverflow.com/questions/number/forth-question-to-meet-the-criteria
https://stackoverflow.com/questions/number/fifth-question-to-meet-the-criteria