N
N
nkno2022-01-24 19:18:52
Flask
nkno, 2022-01-24 19:18:52

Requests not working, readmanga gives 402, what should I do?

parser = reqparse.RequestParser()
        parser.add_argument('manga', required=True)
        parser.add_argument('reqtype', required=True)
        args = parser.parse_args() 

        if args['reqtype'] == 'link':
          url = args['manga']
          response = requests.get(url)
          print(response)
          soup = BeautifulSoup(response.text, 'lxml')
          htmltext = soup.prettify()
          jpname = soup.find('p', class_='expandable-text__text')
            
        
        return {"jpname" : jpname, 'statusApi': 200}, 200  # return data and 200 OK


getInfo?reqtype=link&manga= https://readmanga.io/doch_glavy_iakudza_sozdaet_sa...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2022-01-24
@nkno

You need to get into the habit, when sending requests, to add at least the User-Agent from a normal browser to the headers. Most of the problems will disappear immediately

headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1'}
response = requests.get(url, headers=headers)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question