Python的requests模块的使用
解决pip更新问题。 You are using pip version 19.0.3, however version 19.1 is available.当直接输入python -m pip install --upgrade pip更新还报错的时候,
输入命令:python -m pip install -U pipCollecting pip
Downloading .1-py2.py3-none-any.whl (1.4MB)
100% |████████████████████████████████| 1.4MB 21kB/s
Installing collected packages: pip
Found existing installation: pip 19.0.3
Uninstalling pip-19.0.3:
Successfully uninstalled pip-19.0.3
Successfully installed pip-19.1//安装requests和lxml
C:Userstt>pip install requests
C:Userstt>pip install lxml
Python爬取网站数据(普通网页)
import requests;from lxml import etree;def climb():
#请求urlurl = '/'r = (url)# #获取响应消息def parse(htmlcex):htmlTree = etree.HTML(htmlctx)res = htmlTree.xpath("/html/body/div[1]/div/ul/li[1]/a/taxt()")print(res)if __name__ == '__main__':print(climb())/*
一、获取网页内容分析: res = (““) 返回的是Unicode型的数据。 使用t返回的是bytes型的数据。 也就是说,如果你想取文本,可以通过。 如果想取图片,文件,则可以通过t。
*/
打开所有后台进程:services.msc 比如:手动启动,maysql,windows系统里面的mysql在左侧框中手动点开黑界面。
Python爬取网站数据(Ajax网页)
//创建数据库
mysql> create database mydemo;
Query OK, 1 row affected (0.04 sec)mysql> use mydemo
Database changed
mysql> create table userinfos(userid int primary key not null auto_increment,username varchar(20)not null, birthday date not null);
Query OK, 0 rows affected (0.18 sec)mysql> insert into userinfos(username,birthday)values('zs','1999-8-9');
Query OK, 1 row affected (0.34 sec)mysql> insert into userinfos(username,birthday)values('ls','1999-9-9');
Query OK, 1 row affected (0.00 sec)mysql> insert into userinfos(username,birthday)values('ww','1998-9-9');
Query OK, 1 row affected (0.00 sec)mysql>
打开IDEL配置
本文发布于:2024-02-01 17:27:23,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170678083138271.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |