Python Forum

Full Version: python3 BS4 help
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
import os
import requests
from bs4 import BeautifulSoup

url = "http://localhost/test.php"
html = requests.get(url)
soup = BeautifulSoup(html.content, "lxml")

kd = soup.find("a")
print(kd)
content is:
<a href="?id=test&randomcode=1568465131654894">TEST</a>

how i can get randomcode=[THISCODE] using BS4?
soup.find.a['href'] will get the link. If that is the link then you will just have to parse it out of the string manually.