I am attempting to search for a specific value within an html response using the requests library
import requests
while True:
url = 'https://www.example.com/'
page = requests.get(url, allow_redirects=True, verify=False)
var = page.content
The value would appear to be like a dictionary, but I cannot convert the whole response.content to a dict using : var = dict(page.content) as it gives error "dictionary update sequence element #0 has length 1; 2 is required"
I have attempted to use the re.search method such as this :
searchObj = re.search( r'(.*)id="X" value=(.*?) .*', var, re.M)
if searchObj:
print "search --> searchObj.group() : ", searchObj.group()
but it is not what I am looking for - the end goal is to find a specific value within the content returned from a website request, it would look something like this in the content : <input type="hidden" autocomplete="off" name="test" id="test" value="12345" />
- with the data needing to be extracted as value="12345" or more specifically just the 12345
Thanks in advance