Python Forum
python3 BS4 help - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: python3 BS4 help (/thread-12946.html)



python3 BS4 help - freaknez - Sep-19-2018

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?


RE: python3 BS4 help - metulburr - Sep-20-2018

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.