-
Request
-
URL:http://musicman.migu.cn/activity/ccontent/voteWorks.do
-
Request Method:POST
-
Status Code:200 OK
- 上面的是用 GoogleChrome 抓到的一份数据
- 这是cookie。。不过python的requests模块会自动管理cookie。 只需要先get那个网站一下就好了。
主要是抓到
里面的数据。。
-
Request
-
URL:http://musicman.migu.cn/activity/ccontent/voteWorks.do
-
Request Method:POST
-
Status Code:200 OK
目标 URL 跟方法是post。。然后没了
import requests,time
i = 0
data={"worksid":"###"}
s = requests.session()
s.get('http://musicman.migu.cn/activity/ccontent/queryWorksInfo.do?worksid=1850')
while i < 10 :
i=i+1
z = s.post('http://musicman.migu.cn/activity/ccontent/voteWorks.do',data)
print z.text
然后就没了。。不过只是试验下。。
下面用urllib2,跟urllib模块重写了下。。
import urllib,cookielib
import urllib2
import json
cj=cookielib.CookieJar()
opener=urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
urllib2.install_opener(opener)
for ip in range(23,24):
opener.open('http://musicman.migu.cn/activity/ccontent/queryWorksInfo.do?worksid=####')
req=urllib2.Request('http://musicman.migu.cn/activity/ccontent/voteWorks.do')
data={"worksid":"####"}
ipAddress="192.168.4."+str(ip)
#headers = {'X-Forwarded-For':ipAddress,'User-Agent':'Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20100101 Firefox/11.0'}
req.add_header('Content-Type','application/x-www-form-urlencoded')
req.add_header('X-Forwarded-For',ipAddress)
req.add_header('User-Agent','Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20100101 Firefox/11.0')
for i in range(10):
k=opener.open("http://musicman.migu.cn/activity/ccontent/voteWorks.do",urllib.urlencode(data))
print k.read()