#python 3.5 from urllib.request import urlopen from urllib.request import urlretrieve from bs4 import BeautifulSoup import pymysql conn = pymysql.connect(host='127.0.0.1',user='root',passwd='root',db='pmdb',charset='utf8') cur = conn.cursor()
url = "http://www.mm131.com/xinggan/" html = urlopen(url) soup = BeautifulSoup(html,"lxml") urllist = soup.find(class_='list-left public-box') for i in urllist: jlist = soup.find("dd").find("a")["href"] jliststr='\''+jlist+'\'' # print(jlist) cur.execute("insert into href(href) VALUES ("+jliststr+")") conn.commit() cur.close() conn.close() print("成功!")
相关文章
- Python 提取 PDF 文件的标题、日期和内容并将其存储到 MySQL 数据库中
- Python爬虫爬取王者荣耀英雄信息并保存到图数据库
- python爬取豆瓣电影并保存到数据库
- Python爬取招聘信息,并且存储到MySQL数据库中
- (六)Python爬虫------使用Scrapy库简单爬取天气网城市天气预报信息,并使用MySQL数据库保存数据
- python优化工作流程:python用url爬取页面数据到网页Excel中(一)
- scrapy selenium爬取淘宝商品信息并存储到数据库
- Python爬虫:基于Scrapy的淘宝登陆后实现数据爬取并保存到Mysql
- 猫眼电影爬取(二):requests+beautifulsoup,并将数据存储到mysql数据库
- python2.7爬取豆瓣电影top250并写入到TXT,Excel,MySQL数据库