Bs4 to List/Dictionary Question 08-02-2020, 03:34 AM
#1
This is my current code:
Everything prints out correctly in the output as I need but I want to be able to pull one at a time from it instead of all 15 at once. So how can I changeto output a dictionary or list instead .. thanks
Code:
from bs4 import BeautifulSoup
import requests
# Search Parameter
q=''
# Url to Search for questions
QUERY_URL = "url will be here" + q
req = requests.get(QUERY_URL)
soup = BeautifulSoup(req.text, "html.parser")
# Find all link tags question-hyperlink classes with a limit of 15
questions = soup.find_all("a", class_="question-hyperlink" , limit=15)
# Remove html tags and only print the text
for a in questions:
print(a.text)Everything prints out correctly in the output as I need but I want to be able to pull one at a time from it instead of all 15 at once. So how can I change
Code:
print(a.text)
“I am thankful for all of those who said NO to me. It’s because of them I’m doing it myself.” – Albert Einstein
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)