Answer the question
In order to leave comments, you need to log in
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
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question