A simple solution for crawling search engine keywords with python

Source: Internet
Author: User

Environment: python2.7

Take 360 as an example, use the HTTP intercept tool to obtain the URL, the specific method of obtaining the function depends on the requirements. For example: I would like to crawl her keywords, is to intercept to ... word= end of a string of URLs.

Did not add browser information, system version, it turns out that 360 is very friendly to reptiles =, =.

1, on the treatment of regular expressions, according to the actual situation of their own writing, there is no special uniform format.

2, about the website's code, can modify the processing, here uses the GBK.

1 #CODING=GBK2 " "3 Created on 2014-9-234 5 @author: Administrator6 " "7 ImportUrllib28 ImportUrllib9 ImportReTen  One  AKey = Urllib.quote (Raw_input ("Input Keywords:")) -URL ='http://sug.so.360.cn/suggest?callback=suggest_so&encodein=gbk&encodeout=gbk&format=json& fields=word,obdata&word='+Key -req =Urllib2. Request (URL) the  -  -HTML =Urllib2.urlopen (req). Read () -  +  -SS = Re.findall ("\:\"(.*?) \"", HTML) +  A  forIinchSS: at     PrintI

A simple solution for crawling search engine keywords with python

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.