This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
# pip install pymysql
# pip install requests beautifulsoup4
importpymysql
importrequests
frombs4importBeautifulSoup
if__name__=='__main__':
# 遍历 mysql数据库,然后开启爬虫
# 建立数据库连接
conn=pymysql.connect(
host='10.10.14.203',# 主机名(或IP地址)
port=3306,# 端口号,默认为3306
user='root',# 用户名
password='Password123@mysql',# 密码
charset='utf8mb4'# 设置字符编码
)
# 创建游标对象
cursor=conn.cursor()
# 选择数据库
conn.select_db("ds_db")
# 执行查询操作
cursor.execute(
"SELECT id,full_name FROM t_dm_area where province_id='FD61813E-70A1-42AB-9A8E-141ED4D47B98' order by level_id")