Python Forum

Full Version: Python Scraping Error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I wanted to get .text of <a>, but it simply doesn't work.

Here is my code:
from bs4 import BeautifulSoup
import requests

generatedLink = "MyLink"

page = requests.get(generatedLink)
contents = page.text
soup = BeautifulSoup(contents, "html.parser")

name = soup.find('a',class_=["yt-simple-endpoint", "style-scope", "ytd-video-renderer"])

print(name)
And it returns "None"
Output:
<a id="video-title" class="yt-simple-endpoint style-scope ytd-video-renderer" aria-label="TURNIR 1 VS 1 U LOLU FINALEE!! od korisnika KaLuu Vrijeme streaminga: prije 3 dana 3 sata i 49 minuta 644 pregleda" href="/watch?v=5N4X4hjkzOw" title="TURNIR 1 VS 1 U LOLU FINALEE!!"> TURNIR 1 VS 1 U LOLU FINALEE!! </a>
Ik that something is rly wrong here, but if you can, help me please. Thank you!
Look at what soup source return.
If you see <a> tag in browser dos not always mean that you get that in source Requests get.
This is because of JavaScript,what you see in browser inspect is what has been rendered in DOM.