Python urllib crawls the instance code of Baidu cloud connection, pythonurllib

Source: Internet
Author: User

Python urllib crawls the instance code of Baidu cloud connection, pythonurllib

Looking at my previous programs, I found that I had written something About Baidu cloud resources, which was just written by myself when I wanted to watch Transformers, at that time, the first time I came into contact with python, I wrote this program for about two days. I learned the python language. I can see that the code at that time was really low. Although it is not very good now, Haha, I have been learning and don't explain it too much. I just forgot what the variable declaration is (manually proud ), I didn't even write files at the time. I didn't even know that the class can be initialized through init. Alas, I learned so much about python. Thanks to python.

From bs4 import BeautifulSoupimport urllibimport requestsimport readr = [] ''' perform url encoding for the search Resource Name ''' search _ text = raw_input ('Enter the search Resource Name :') search_text = search_text.decode ('gbk') search_text = search_text.encode ('utf-8') search_text = urllib. quote (search_text) ''' get file address ''' home = urllib. urlopen ('HTTP: // www.panduoduo.net/s/name/'{search_text) ''' get Baidu cloud address ''' def getbaidu (adr): for I in adr: url = urllib. urlopen ('HTTP: // www.panduoduo.net '+ I) bs = BeautifulSoup (url) bs1 = bs. select ('. dbutton2 ') href = re. compile ('HTTP \ % (\ % | \ d | \ w | \/| \.) * ') B = href. search (str (bs1) name = str (bs. select ('. center ')). decode ('utf-8') text1 = re. compile ('\ 

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

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.