-
常見文檔讀取
查看全部 -
python操作mysql1
查看全部 -
python操作mysql
查看全部 -
from?urllib.request?import?urlopen from?bs4?import?BeautifulSoup?as?bs import?pymysql.cursors #?打開鏈接并讀取,把結(jié)果用utf-8編碼 resp?=?urlopen("http://www.umei.cc/bizhitupian/meinvbizhi/").read().decode("utf-8") #?使用html.parser解析器 soup?=?bs(resp,"html.parser") #?格式化輸出 #print(soup.prettify()) #print(soup.img)??#?獲取img標(biāo)簽 #print(soup.find_all('img'))??#?獲取所有img標(biāo)簽信息 for?link?in?soup.find_all('img'):???#?從文檔中找到所有img標(biāo)簽的鏈接 ????#print(link.get('src')) ????#print(link.get('title')) ????#?獲取數(shù)據(jù)庫(kù)連接 ????connection?=?pymysql.connect(host="localhost",?user="root",?password="root",?db="python_mysql",?charset="utf8mb4") ????try: ???????????#獲取會(huì)話指針 ???????????with?connection.cursor()?as?cursor: ???????????????#創(chuàng)建sql語(yǔ)句 ???????????????sql?=?"insert?into?`girl_image`(`title`,?`urlhref`)?values?(%s,?%s)" ???????????????#?執(zhí)行sql語(yǔ)句 ???????????????cursor.execute(sql,?(str(link.get('title')),?link.get('src'))) ???????????????#提交 ???????????????connection.commit() ????finally: ???????????connection.close()
查看全部 -
Python操作mysql步驟3
查看全部 -
Python操作mysql使用步驟2
查看全部 -
Python操作mysql使用步驟
查看全部 -
存儲(chǔ)數(shù)據(jù)到MySQL
查看全部 -
beautiful soup
www.crummy.com/software/BeautifulSoup/#Download
查找修改樹形結(jié)構(gòu),提供一些工具,可以解析文檔
默認(rèn)Unicode,utf-8
支持lxml和html5lib解析器
文檔地址:https://www.crummy.com/software/BeautifulSoup/bs4/doc.zh/#id4
查看全部 -
urllib使用post方式
查看全部 -
urllib使用POST方式發(fā)送數(shù)據(jù)
查看全部 -
模擬瀏覽器 攜帶User-Agent頭 ? ?
req = request.Request(url) ? ?
req.add_header(key, value) ? ?
resp = request.urlopen(req) ? ?
print(resp.read().decode("utf-8"))
查看全部 -
urllib庫(kù)的使用步驟
查看全部 -
urllib的用法
查看全部 -
安裝BeautifulSoup4
查看全部
舉報(bào)