当前位置:网站首页>Crawler: from entry to imprisonment (II) -- Web collector
Crawler: from entry to imprisonment (II) -- Web collector
2022-07-28 14:51:00 【Youth is short!】
Go straight to the theme
at present python3 There are already very perfect requests modular , We mainly use this module to crawl web data
requests modular :python A module based on network request of Zhongyuan , Very powerful , Simple and convenient , Very efficient .
effect : Simulate browser to send request .
How to use :(requests Module coding process )
- Appoint url
- Initiate request
- Get response data
- Persistent storage
First , Open the terminal installation environment
pip install requestsAfter the environment is installed , We can formally start to build the body of crawl code
Create a python file , Import requests modular
import requests
if __name__ == "__main__":The target site's URL The address is stored in a string variable
Must be based on “ character string ” stored
URL=" The target URL you crawled URL"utilize requests Modular get Method to send a request to the target web page
result=requests.get(url=URL)Then store the content of the web page in the file of the local corresponding format
with open("./test.html","w",encoding="utf-8") as fp
fp.write(result.text)Print end prompt
print(" Crawling over !")A simple web page raw data acquisition device is done , You can preview the crawled web page locally
Add a concept !
Ajax asked :Ajax namely Asynchronous Javascript And XML( asynchronous JavaScript and XML) stay 2005 By the Jesse James Garrett New terminology proposed , Used to describe a technology that uses a collection of existing technologies ‘ new ’ Method , Include : HTML or XHTML, CSS, JavaScript, DOM, XML, XSLT, And most importantly XMLHttpRequest. [3] Use Ajax Technology web applications can quickly present incremental updates to The user interface On , Instead of overloading ( Refresh ) The entire page , This allows the program to respond more quickly to user actions .
边栏推荐
猜你喜欢
![[ecmascript6] other new interface features](/img/da/377f93d83b6722bf250d270e4eea28.png)
[ecmascript6] other new interface features

文件批量重命名工具Bulk Rename Utility

The method of implementing simple student achievement management system with C language

Xcode编写SwiftUI代码时一个编译通过但导致预览(Preview)崩溃的小陷阱

多所“双一流”大学,保研预报名启动!

一些企业数据平台建设的思考

Focus on differentiated product design, intelligent technology efficiency improvement and literacy education around new citizen Finance

Raspberry pie foundation | summarize and record some operations in the learning process of raspberry pie

@Solution to DS ('slave') multi data source compatible transaction problem

35道MySQL面试必问题图解,这样也太好理解了吧
随机推荐
为 @CloudStorage 添加了类 @Published 的能力
八、picker用法 下拉框选择效果
Product Manager
Swiftui 4.0's new navigation system
2022高处安装、维护、拆除考试题库及在线模拟考试
Swiftui layout - size (bottom)
String转为long 类型报错原因:要转为long必须是int、double、float型[通俗易懂]
复制excel行到指定行
Getting started with scottplot tutorial: getting and displaying values at the mouse
【LeetCode】 贴纸拼词(动态规划)
(function(global,factory){
The second pre class exercise
How to perform batch operations in core data
Redis persistence
Force deduction solution summary 1331 array sequence number conversion
pix2pix
Hcip day 11
Several methods of opening URL in swiftui view
linux安装redis
2022 high altitude installation, maintenance, removal of examination question bank and online simulated examination