我正试图上传一张图片到易趣-克莱恩泽根有限公司用mechanize,但每次我尝试它,我得到一个403错误。你知道吗
登录代码:
import mechanicalsoup
browser = mechanicalsoup.StatefulBrowser()
browser.set_user_agent(
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36')
a = browser.open('https://www.ebay-kleinanzeigen.de/m-einloggen.html')
browser.select_form('#login-form')
# browser.get_current_form().print_summary()
browser['loginMail'] = 'testaccount@8.dnsabr.com'
browser['password'] = 'testaccount'
browser.submit_selected()
选择要列出产品的类别:
response = browser.open(
'https://www.ebay-kleinanzeigen.de/p-anzeige-aufgeben.html#?path=161/173/motorola_handy&isParent=false')
crsf = response.soup.find('input', {'name': '_csrf'})['value']
payload_select_category = {"_csrf": crsf,
"parentCategoryId": "210",
"categoryId": "223",
"attributeMap[autoteile_reifen.art_s]": "ersatz_reparaturteile"}
response = browser.post('https://www.ebay-kleinanzeigen.de/p-anzeige-aufgeben-schritt2.html', payload_select_category)
上载图像:
img_file = open(r'C:/Users/Oli/Google Drive/IMG_20190616_153432.jpg', 'rb')
payload_img_upload = {'name': 'Image.jpg'}
file = {'name': 'Image.jpg',
'file': ('Image.jpg', img_file, 'image/jpeg')}
response = browser.post('https://www.ebay-kleinanzeigen.de/p-bild-hochladen.html', payload_img_upload, files=file)
顺便说一下,我在这里提供的登录数据是有效的。你知道吗
尝试使用以下代码:
另外,还有这种编码。图片是以某种编码方式上传的,你能告诉我这是哪种编码吗。我认为这就是问题所在:
。你知道吗
相关问题 更多 >
编程相关推荐