I am having some trouble printing only a specific value of the scraped html
This the specific line of HTML my program scrapes for
<input name="form_key" type="hidden" value="MmghsMIlPm5bd2Dw"/>
My code is as follows
import requests, time
from bs4 import BeautifulSoup
from colorama import Fore, Back, Style, init
print(Fore.CYAN + "Lets begin!"")
init(autoreset=True)
url = raw_input("Enter URL: ")
print(Fore.CYAN + "\nGetting form key")
r = requests.get(url)
soup = BeautifulSoup(r.content, "html.parser")
data = soup.find_all("input", {'name': 'form_key', 'type':'hidden'})
for data in data:
print(Fore.YELLOW + "Found Form Key:")
print(data)
The program scrapes it fine, but prints the entire line where I desire to only print "MmghsMIlPm5bd2Dw" (no quotes)
How can I achieve this??
I have tried things like
print soup.find(data).text
And
last_input_tag = soup.find("input", id="value")
print(last_input_tag)
But nothing has seemed to really work