Python crawls the seven-color lottery history

Source: Internet
Author: User

1. Because people can not be endlessly learning, and occasionally want to do something else, yesterday bored to write python, of course, I admit that I work basically is learning work, in this post I also stayed for more than three years, or that sentence asked me what will I give you say I what will, just a matter of time! All right, don't spit out the groove, everyone together refueling! Direct to code and results.

2. Program code:

# Encoding:utf-8
Import re
From Urllib Import Request
Import gzip
def gethtml (URL): #获取页面的源代码
page = Request.urlopen (URL)
html = Page.read ()
HTML = gzip.decompress (HTML)
html = Html.decode (' Utf-8 ')
Regall = R ' <td><b class= "c_ba2636" >.*</b> '
Balllist = Re.findall (regall,html)
For I in Balllist:
num = i[-17:-4]
Print (i[-17:-4])
In_put = open (' d:/crawler/file ', ' a ')
In_put.write (' \ n ')
In_put.write (num)
In_put.close ()
Return num
Print (gethtml (' http://caipiao.163.com/award/qxc/'))
3. Results

FUN, FUN!!!!! Play with Fun python!

Python crawls the seven-color lottery history

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.