第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

sql語法錯(cuò)誤求解釋

#coding:utf8
from bs4 import? BeautifulSoup as bs
import urllib2
import re
import pymysql
url="http://baike.baidu.com/view/20965.htm"
resp=urllib2.urlopen(url).read().decode("utf-8")
soup=bs(resp,"html.parser")
links=soup.find_all("a",href=re.compile(r"^http://baike.baidu"))
for link in links:
?? ?print link.get_text()+": "+link["href"]
?? ?print "----------------------------"
?? ?try:
?? ??? ?conn=pymysql.connect(
?? ??? ??? ?host="127.0.0.1",
?? ??? ??? ?port=3306,
?? ??? ??? ?user="root",
?? ??? ??? ?passwd="root",
?? ??? ??? ?db="test",
?? ??? ??? ?charset="utf8")
?? ??? ?cursor=conn.cursor()
?? ??? ?sql="insert into 'url'('urlname','urlhref') values(%s,%s)"
?? ??? ?cursor.execute(sql,(link.get_text(),link["href"]))
?? ??? ?conn.commit()
?? ?except Exception as e:
?? ??? ?print e
cursor.close()
conn.close()



What is free software??: http://baike.baidu.com/redirect/5e79r1K4R-2NomzcGBBrbrhZlzPTF6qJ-9jFYpyAZVCkUn8WxubcnZcF8UNczadKXEZLleFlvgmO2VuBgV5GFsx1We0EldQ-Wn8
----------------------------
(1064, u"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''url'('urlname','urlhref') values('What is free software?\xa0','http://baike.baidu' at line 1")
GNU General Public License?: http://baike.baidu.com/redirect/b225K4w1tT1KqEZN29N--HgZRFhWwPsGeFgE0SekI62-tSjC3z-upHovI9zUdmYcMi8dBxcoW49LoCGdjljImC6P
----------------------------
(1064, u"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''url'('urlname','urlhref') values('GNU General Public License\xa0','http://baike.b' at line 1")
Explaining BSD?: http://baike.baidu.com/redirect/ef97prp0tq724owayibkn13MQAjSUk8mg15fMOwOKFTg_1bDygSpMw1P9SUU3gsb9LLnIE685k5DFdqA2-JxNykOfop8UCRiWHTLu3L8I2itYKHxbHmgVerJILjiY3U
----------------------------
(1064, u"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''url'('urlname','urlhref') values('Explaining BSD\xa0','http://baike.baidu.com/red' at line 1")
[Finished in 1.3s]

正在回答

1 回答

??charset="utf8") ===>'utf8mb4' 試試

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
python遇見數(shù)據(jù)采集
  • 參與學(xué)習(xí)       59664    人
  • 解答問題       209    個(gè)

本教程讓你初步掌握Python進(jìn)行數(shù)據(jù)采集,創(chuàng)造屬于你的價(jià)值

進(jìn)入課程

sql語法錯(cuò)誤求解釋

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)