Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
python3 BS4 help
#1
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?
Reply
#2
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.
Recommended Tutorials:
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020