0

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

1 Answer 1

1

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.