So with following im adding Script from a webpage to a dict and afterwards trying to find a certain string in it, then get the 13 letters after:
for link in productlinks:
try:
s = HTMLSession()
r = s.get(link)
response = urllib3.PoolManager().request(
"GET", link, headers={'User-Agent': "python"})
soup = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
title = r.html.find('h1.rd-title', first=True).text
script2 = []
script1 = soup.findAll("script")[2]
script2.append(script1)
special_string = '"ean",values:[{text:"'
x_letters_afterwards = 13
result = re.findall(re.escape(special_string) + ".{" + x_letters_afterwards + "}", script2)
print(result)
except:
print("...")
The problem is the for loop try seems to break to an except through something as it always just prints "..." instead of the string i try to extract (or something else in general).
An example of the output where the string should be found: https://pastebin.com/xvzQ456P
I dont know what to do...