Simple Python crawler __python

Source: Internet
Author: User

A simple Python crawler program that's good for practice.

#读出一个URL下的a标签里href地址为. All addresses of HTML

A simple Python crawler program that's good for practice.

#读出一个URL下的a标签里href地址为. All addresses of HTML

#!/usr/bin/python
# Filename:test.py

Import Urllib

Content = Urllib.urlopen (' http://codecloud.net '). Read ()
S1 = 0
While S1 >= 0:
Begin = Content.find (R ' <a ', S1)
M1 = Content.find (R ' href= ', begin)
M2 = content.find (R ' > ', m1)
if (Content[m1:m2].find (r '. html ')!=-1):
M2 = Content.find (r '. html ', M1)
url = content[m1+6:m2+5]
Print URL
S1 = m2


Turn from: http://codecloud.net/python-562.html

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.