zoukankan      html  css  js  c++  java
  • Web crawler study(1)

    1. setup the python3 enviromemt via download the excuted files from the website https://www.python.org/downloads/

    2.Atfer seting up ,confirm that whether the enviroment is successful or not .

       open the CMD windows  /  Linux terminal  to type "python" ,then press the enter  key.

    3.create a python file for coding.eg :demo.py

      # coding=gbk                                      #it can be avoid the syntaxerror:non-utf-8 code starting with x3
      

          import urllib.request                             # urllib.request  is a package which usally used to get the infomation form the web pages
       
      url="http://www.baidu.com"                  # the web site that we want to get the information from it

      response=urllib.request.urlopen(url)      # get the reponse from the web server,the expected result is the information  that we wanted.
     
      html=response.read()                          # return the information the Binary string,so that the infromation can be displayed.
     
      codeOfHtml=html.decode('utf-8')          #decoding the information
     
      print(codeOfHtml)                                #print the information

    4. Run the demo.py script

  • 相关阅读:
    数据结构:练习题
    Node.js尝鲜——留言功能
    html+JavaBean+jsp实现用户注册
    我的安全之路——Web安全篇
    Java模拟储蓄卡和信用卡
    AngularJS尝鲜——联动菜单
    AngularJS尝鲜——Ajax请求
    AngularJS尝鲜——增减商品购买量
    Knight Tournament (set)
    Anniversary party (树形DP)
  • 原文地址:https://www.cnblogs.com/yongdaiblog-201409/p/6731056.html
Copyright © 2011-2022 走看看