Python crawlers count The total revenue generated by the demo Master website

Source: Internet
Author: User




Use Python crawlers to calculate the total revenue generated from the Demo Master website ...

#!/usr/bin/env python#coding:utf-8import requestsimport jsonfrom bs4 import  Beautifulsoupdef demodashi (URL):     response = requests.get (URL)      html = response.text    html = json.loads (HTML)     totalpage = html[' Totalpage ']    currentpage =  html[' currentpage ']    data = html[' data ']     demouserdict = {}    for demo in data:         demouserdict[demo[' ID ']] = demo    pircesumpage =  0    for id in demouserdict:         downnum = demouserdict[id][' Down_num ']         usrurl =  ' Http://www.demodashi.com/demo/%s.html '  % id        header={              ' Accept ':  ' text / html, application /  xhtml + xml, application / xml;q = 0.9, image / webp, *  / *;q = 0.8 ',             ' Accept - language ':  ' zh - cn, zh;q = 0.8 ',              ' Cookie ':  ' useridinfocookie =  xyq4jjpg8pgw8leumhd;usersessioninfocookie = 1abe726154ab6aa9e8e771ad3188ed8c; jsessionid = bbaa6dcfc9e2ce2568aeebf38eb3f101; hm_lvt_27ece87947b753bb8e85404fdffce737 = 1521615577, 1521716172, 1522033433,  1522042544; hm_lpvt_27ece87947b753bb8e85404fdffce737 = 1522042544 ',             ' user - agent ':  ' mozilla / 5.0 (windows nt 6.1 ; WOW64)  applewebkit / 537.36 (Khtml, likegecko)  chrome / 55.0.2883.87ubrowser  / 6.2.3964 .2safari / 537.36 ',         }         response = requests.get (Usrurl,headers=header)          html = response.text         soup = beautifulsoup (HTML, ' lxml ')         try:             pirce = soup.find (' div ', class_= ' sj-dm dsj-l ') .b.string        except:             pirce = 0         pircesumpage&nBsp;+= int (Pirce) *int (downnum)     return pircesumpage,totalpagedef bankuai ( URL):     totalpage = demodashi (URL) [1]    totalpirce =  0    for page in range (0,totalpage):         url =  ' http://www.demoku.com/portal/demo/getDemoList4page?queryString=&toPage= %s&orderby=&type=&typeid=&ptype=&to1=demo&to2=buy&userid= '  % page         totalpirce += demodashi (URL) [0]     return totalpirceif __name__ ==  ' __main__ ':     '       All  :http://www.demodashi.com/portal/demo/getdemolist4page?querystring=&topage=0&orderby= &type=&typeId=&ptype=&to1=demo&to2=buy&userId=     all   (popular, recommended, Latest)    &NBSp;http://www.demodashi.com/portal/demo/getdemolist4page?querystring=&topage=0&orderby=downloadmax &type=&typeid=&ptype=&to1=demo&to2=buy&userid=    http:// www.demodashi.com/portal/demo/getdemolist4page?querystring=&topage=0&orderby=avgmarkmax&type=& Typeid=&ptype=&to1=demo&to2=buy&userid=    http://www.demodashi.com/portal /demo/getdemolist4page?querystring=&topage=0&orderby=uploadnew&type=&typeid=&ptype=& to1=demo&to2=buy&userid=     Big Data     http://www.demodashi.com/ portal/demo/getdemolist4page?querystring=&topage=0&orderby=downloadmax&type=1&typeid=2& ptype=2&to1=demo&to2=buy&userid=    http://www.demodashi.com/portal/demo/ getdemolist4page?querystring=&topage=0&orderby=avgmarkmax&type=1&typeid=2&ptype=2&to1= demo&to2=buy&userid=    http://www.demodashi.com/portal/demo/getdemolist4page?querystring=&topage=0&orderby= uploadnew&type=1&typeid=2&ptype=2&to1=demo&to2=buy&userid=     Mobile Technology     http://www.demodashi.com/portal/demo/getDemoList4page?queryString=&toPage=0& orderby=downloadmax&type=1&typeid=9&ptype=9&to1=demo&to2=buy&userid=     http://www.demodashi.com/portal/demo/getdemolist4page?querystring=&topage=0&orderby=avgmarkmax &type=1&typeid=9&ptype=9&to1=demo&to2=buy&userid=    http:// www.demodashi.com/portal/demo/getdemolist4page?querystring=&topage=0&orderby=uploadnew&type=1& Typeid=9&ptype=9&to1=demo&to2=buy&userid=    web Series      http://www.demodashi.com/portal/demo/getdemolist4page?querystring=&topage=0&orderby=downloadmax& Type=1&typeid=12&ptype=12&to1=demo&to2=buy&userid=    http://www.demodashi.com/portal/demo/ getdemolist4page?querystring=&topage=0&orderby=avgmarkmax&type=1&typeid=12&ptype=12& To1=demo&to2=buy&userid=    http://www.demodashi.com/portal/demo/getdemolist4page? Querystring=&topage=0&orderby=uploadnew&type=1&typeid=12&ptype=12&to1=demo&to2=buy &userId=     Front-end development     http://www.demodashi.com/portal/demo/ getdemolist4page?querystring=&topage=0&orderby=downloadmax&type=1&typeid=26&ptype=26& To1=demo&to2=buy&userid=    http://www.demodashi.com/portal/demo/getdemolist4page? Querystring=&topage=0&orderby=avgmarkmax&type=1&typeid=26&ptype=26&to1=demo&to2= buy&userid=    http://www.demodashi.com/portal/demo/getdemolist4page?querystring=& Topage=0&orderby=uploadnew&type=1&typeid=26&ptype=26&to1=demo&to2=buy&userid=     System and programming     http://www.demodashi.com/portal/demo/getDemoList4page?queryString=&toPage=0& orderby=downloadmax&type=1&typeid=31&ptype=31&to1=demo&to2=buy&userid=     http://www.demodashi.com/portal/demo/getdemolist4page?querystring=&topage=0&orderby= avgmarkmax&type=1&typeid=31&ptype=31&to1=demo&to2=buy&userid=     Http://www.demodashi.com/portal/demo/getDemoList4page?queryString=&toPage=0&orderBy=uploadNew&type =1&typeid=31&ptype=31&to1=demo&to2=buy&userid=     Internet Applications      http://www.demodashi.com/portal/demo/getdemolist4page?querystring=&topage=0&orderby= downloadmax&type=1&typeid=47&ptype=47&to1=demo&to2=buy&userid=     Http://www.demodashi.com/portal/demo/getdemolist4page?querystring=&topage=0&orderby=avgmarkmax&type=1&typeid=47&ptype=47 &to1=demo&to2=buy&userid=    http://www.demodashi.com/portal/demo/ Getdemolist4page?querystring=&topage=0&orderby=uploadnew&type=1&typeid=47&ptype=47&to1 =demo&to2=buy&userid=     Scheme Design     http://www.demodashi.com/ portal/demo/getdemolist4page?querystring=&topage=0&orderby=downloadmax&type=1&typeid=50& ptype=50&to1=demo&to2=buy&userid=    http://www.demodashi.com/portal/demo/ getdemolist4page?querystring=&topage=0&orderby=avgmarkmax&type=1&typeid=50&ptype=50& To1=demo&to2=buy&userid=    http://www.demodashi.com/portal/demo/getdemolist4page? Querystring=&topage=0&orderby=uploadnew&type=1&typeid=50&ptype=50&to1=demo&to2=buy &userId=     ProductsDesign     http://www.demodashi.com/portal/demo/getDemoList4page?queryString=&toPage=0& orderby=downloadmax&type=1&typeid=52&ptype=52&to1=demo&to2=buy&userid=     http://www.demodashi.com/portal/demo/getdemolist4page?querystring=&topage=0&orderby= avgmarkmax&type=1&typeid=52&ptype=52&to1=demo&to2=buy&userid=     Http://www.demodashi.com/portal/demo/getDemoList4page?queryString=&toPage=0&orderBy=uploadNew&type =1&typeid=52&ptype=52&to1=demo&to2=buy&userid=    ui Design      http://www.demodashi.com/portal/demo/getdemolist4page?querystring=&topage=0&orderby= downloadmax&type=1&typeid=54&ptype=54&to1=demo&to2=buy&userid=     http://www.demodashi.com/portal/demo/getdemolist4page?querystring=&topage=0&orderby=avgmarkmax& type=1&typeid=54&ptype=54&to1=demo&to2=buy&userid=    http://www.demodashi.com/portal/demo/ Getdemolist4page?querystring=&topage=0&orderby=uploadnew&type=1&typeid=54&ptype=54&to1 =demo&to2=buy&userid=     '     urllist = ['/http www.demoku.com/portal/demo/getdemolist4page?querystring=&topage=1&orderby=&type=&typeid=& Ptype=&to1=demo&to2=buy&userid= ']    for url in urllist:         print  ' Demo Master website total revenue:  '  + str (Bankuai (URL))


If the content violates the privacy, contact me will delete immediately ..... (961769710)

Python crawlers count The total revenue generated by the demo Master website

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.