#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("成功!")

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-02-24
  • 2022-12-23
  • 2021-10-25
  • 2021-09-16
  • 2021-10-13
猜你喜欢
  • 2021-11-20
  • 2021-06-21
  • 2022-12-23
  • 2022-02-21
  • 2021-06-04
  • 2022-12-23
  • 2021-07-20
相关资源
相似解决方案