Reputation: 29
Trying to find the formkey but getting the error:
TypeError: 'NoneType' object is not subscriptable
On this webpage.
need to find the value. What I am searching for can be found at view-source:https://wellgosh.com/customer/account/create/ and control+f name="form_key" value=
formkey_acc = soup.find('input', {'name': 'form_key'})['value']
s = requests.session()
def c_acc():
acc = s.get('https://wellgosh.com/customer/account/create/')
soup = bs(acc.text, 'html.parser')
formkey_acc = soup.find('input', {'name': 'form_key'})['value']
print(formkey_acc)
formkey_acc = soup.find('input', {'name': 'form_key'})['value']
TypeError: 'NoneType' object is not subscriptable
Upvotes: 0
Views: 243
Reputation: 312
They are 403'ing on the default user-agent of requests...
import requests
from bs4 import BeautifulSoup as bs
def c_acc(s):
acc = s.get(
'https://wellgosh.com/customer/account/create/',
headers={'User-Agent': "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36"}
)
soup = bs(acc.text, 'html.parser')
formkey_acc = soup.find('input', {'name': 'form_key'}).get('value')
print(formkey_acc)
s = requests.session()
c_acc(s)
Upvotes: 1