我对POST这样的网站感到困惑

时间:2018-09-09 14:19:18

标签: python python-requests

好的,这个站点只是一个例子,但我希望您对我的困惑有个大致的认识。

这是我为网站快速编写的代码:

payload = {'firstname': 'Ryanous', 'lastname': 'Smti','email': 'thingy7237@gmail.com', 'PASSWORD': 'yaya7893478934',}

r = requests.post(WHAT_URL??? , data = payload)
time.sleep(1.7834734)
print(r.content)

所以可以说我正尝试在这里(https://reg.ebay.com/reg/PartialReg)上使用Python Requests进行注册。因此,当我查看“网络”选项卡以查看注册时会发生什么,这三件事发生了。当我输入自己的名字和姓氏时,我输入的内容会发送到https://reg.ebay.com/reg/track。当我输入电子邮件时,它既会发布到https://reg.ebay.com/reg/track也会发布到https://reg.ebay.com/reg/ajax。当我输入密码时,网络控制台会显示它仅对https://reg.ebay.com/reg/ajax进行POST。但是,当我发布到这些网址中的任何一个时,它不起作用。发生了什么事?

提前谢谢!

1 个答案:

答案 0 :(得分:1)

这是发送到ebay的完整请求,被 fiddler 拦截,

POST https://reg.ebay.com/reg/PartialReg HTTP/1.1
Host: reg.ebay.com
Connection: keep-alive
Content-Length: 741
Cache-Control: max-age=0
Origin: https://reg.ebay.com
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.81 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Referer: https://reg.ebay.com/reg/PartialReg
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
Cookie: aam_uuid=60231779855192746434487614328071690113; cid=o48ObOkRdLGL6CaS%231913659548; AMCV_A71B5B5B54F607AB0A4C98A2%40AdobeOrg=-1758798782%7CMCIDTS%7C17777%7CMCMID%7C60242666160665362384488940468295249468%7CMCAAMLH-1536475733%7C3%7CMCAAMB-1536475733%7CRKhpRz8krg2tLO6pguXWp5olkAcUniQYPHaMWWgdJ3xzPWQmdj0y%7CMCCIDH%7C-1206723612%7CMCOPTOUT-1535878133s%7CNONE%7CMCAID%7CNONE; npii=btguid/a9479d531640ad4ba1dfdf77fff991ba5d6cbc38^cguid/a947a4721640aa46a1733082f26b543a5d6cbc38^; JSESSIONID=1163EA25E5D28E6D3FEFE265DC42CA03; __gads=ID; BidWatchConf=CgADJACBbloHkOTYwNmFiNzhmMTM3NDBjNzgyY2I1ZmE4MTk2MjdiMDDXi0VO; ns1=BAQAAAWWsLakOAAaAAKUADV12Y+QxODE1MTcyNTc4LzA7ANgAWF12Y+RjODR8NjAxXjE1MzI2MjQwODExNDJeWldNM1pHSXROUT09XjFeM3wyfDV8NHw3fDExXjFeMl40XjNeMTJeMTJeMl4xXjFeMF4xXjBeMV42NDQyNDU5MDc1q4Mtw+9aMn7pnSq6mpxylOOxeMc*; dp1=bkms/in5f579764^u1f/ANUJ5d7663e4^u1p/ZWM3ZGItNQ**5d7663e4^bl/INen-US5f579764^expt/00015326240648785c4a9681^pbf/%235280000000e000e000008180c20000045d7663e4^; s=CgAD4ACBbloHkYmVjNDM4N2YxNjUwYWRhMWY1MTJhOGFiZmZmYTQ0NzW5qXev; nonsession=BAQAAAWWsLakOAAaAAJ0ACF12Y+QwMDAwMDAwMQFkAAJddmPkI2EACAAcW7y9ZDE1MzQzNTQ4MzN4MzMyNjQzNDYxOTEzeDB4Mk4AMwAJXXZj5DkwMDAxLFVTQQDLAAFblTdsOABAAAdddmPkZWM3ZGItNQAQAAdddmPkZWM3ZGItNQDKACBk+zHkYTk0NzlkNTMxNjQwYWQ0YmExZGZkZjc3ZmZmOTkxYmEABAAHXT6SeGVjN2RiLTUAnAA4XXZj5G5ZK3NIWjJQckJtZGo2d1ZuWStzRVoyUHJBMmRqNkFNa1llZ0Q1S0hwZ1NkajZ4OW5ZK3NlUT09eh5LsYJBoaoQK/KuV1EGI2Ak2B4*; ebay=%5Esbf%3D%23%5Ejs%3D1%5Epsi%3DAxDh%2FH1E*%5E; ds2=sotr/b7r1Uzzzzzzz^

isSug=false&countryId=1&userid=&ru=http%3A%2F%2Fwww.ebay.com&firstname=Ryanous&lastname=Smti&email=thingy7237%40gmail.com&PASSWORD=yaya7893478934&checkbox-default=on&mblChk=0&promotion=true&iframeMigration1=true&mode=1&frmaction=submit&tagInfo=ht5%253DAQAAAWSqr7ETAAUxNjRkNzgyZjgyNi5hZDc4ZWEyLjNhOGMuZmZmZjc3Yjm7B%25252BT3Tthy8Kdb8nvEHRiRxsMukQ**%257Cht5new%253Dfalse%2526usid%253Dbec438aa1650ada1f517e302ffff91fc&hmvb=&isGuest=0&idlstate=&profilePicture=&agreement=Terms+and+conditions&signInUrl=https%253A%252F%252Fsignin.ebay.com%252Fws%252FeBayISAPI.dll%253FSignIn%2526regUrl%253Dhttps%25253A%25252F%25252Freg.ebay.com%25252Freg%25252FPartialReg&personalFlag=true&isMobilePhone=&_trksid=p2052190&ets=AQADAAAAEOLzuussjt0oS0JDE3e8D_o%0D%0A

从以上原始请求中您可以看到,您需要将所有这些值发布到https://reg.ebay.com/reg/PartialReg。数据字典中的某些键可以从ebay的html页面源代码中提取。

data = {
    "isSug": "false",
    "countryId": "1",
    "userid": "",
    "ru": "http%3A%2F%2Fwww.ebay.com",
    "firstname": "Ryanous",
    "lastname": "Smti",
    "email": "thingy7237%40gmail.com",
    "PASSWORD": "yaya7893478934",
    "checkbox-default": "on",
    "mblChk": "0",
    "promotion": "true",
    "iframeMigration1": "true",
    "mode": "1",
    "frmaction": "submit",
    "tagInfo": "ht5%253DAQAAAWSqr7ETAAUxNjRkNzgyZjgyNi5hZDc4ZWEyLjNhOGMuZmZmZjc3Yjm7B%25252BT3Tthy8Kdb8nvEHRiRxsMukQ**%257Cht5new%253Dfalse%2526usid%253Dbec438aa1650ada1f517e302ffff91fc",
    "hmvb": "",
    "isGuest": "0",
    "idlstate": "",
    "profilePicture": "",
    "agreement": "Terms+and+conditions",
    "signInUrl": "https%253A%252F%252Fsignin.ebay.com%252Fws%252FeBayISAPI.dll%253FSignIn%2526regUrl%253Dhttps%25253A%25252F%25252Freg.ebay.com%25252Freg%25252FPartialReg",
    "personalFlag": "true",
    "isMobilePhone": "",
    "_trksid": "p2052190",
    "ets": "AQADAAAAEOLzuussjt0oS0JDE3e8D_o%0D%0A",
}