![]() |
|
Bs4 to List/Dictionary Question - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: Python (https://sinister.ly/Forum-Python) +--- Thread: Bs4 to List/Dictionary Question (/Thread-Bs4-to-List-Dictionary-Question) |
Bs4 to List/Dictionary Question - mudrig - 08-02-2020 This is my current code: 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)RE: Bs4 to List/Dictionary Question - mudrig - 08-07-2020 (08-07-2020, 11:18 AM)sefefew Wrote: Declare a list, Exactly what I was looking for thanks RE: Bs4 to List/Dictionary Question - Ciceniss - 09-06-2021 It is not easier to buy a dictionary with the language you need, that is, it already depends on the purpose of each one. For example, I wanted to learn as many [link redacted] as possible, and I bought a dictionary from Amazon with the specifics of the terms. You can also find dictionaries with grammar or phrases. But what is the purpose of this whole thing? I can't understand, so could you please explain to me, because I find the scheme quite interesting. It wouldn't hurt to delve deeper into other areas, but it's personal development. |