Python intercepts search engine keywords

Source: Internet
Author: User

This code is to learn the basic syntax of Python, refer to an online video write code, the function is to intercept search engine 360 keywords.

Code:

1 #!/usr/bin/python2 #Encoding:utf-83 4 ImportUrllib5 ImportUrllib26 ImportRe7 Import Time8  fromRandomImportChoice9 TenIPList = ['1.9.189.65:3128','27.24.158.130:80','27.24.158.154:80'] One  AListkeywords = ["Group","Technology"] -  forIteminchlistkeywords: -IP =Choice (iplist) theGJC =urllib.quote (item) -URL ="http://sug.so.360.cn/suggest?callback=suggest_so&encodein=utf-8&encodeout=utf-8&word="+GJC -headers = { -         "GET": URL, +         "Host":"sug.so.360.cn",  -         "Referer":"http://www.so.com/",  +         "user-agent":"mozilla/5.0 (X11; Linux i686) applewebkit/537.36 (khtml, like Gecko) Ubuntu chromium/37.0.2062.120 chrome/37.0.2062.120 safari/537.36 " A     } at  -     #Proxy_support = urllib2. Proxyhandler ({"http": "//" +ip}) -  -     #opener = Urllib2.build_opener (proxy_support) -     #Urllib2.install_opener (opener) -req =Urllib2. Request (URL) in  -      forKeyinchheaders: to Req.add_header (Key, Headers[key]) +  -HTML =Urllib2.urlopen (req). Read () the     PrintHTML *  $SS = Re.findall ("\"(.*?) \"", HTML)Panax Notoginseng      forIteminchSS: -         PrintItem the          +Time.sleep (3)

The main use of Python from the I-band of several libraries, usage can view the help document.

Python intercepts search engine keywords

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.