python爬虫
来源:互联网 发布:苏州中国软件名城 编辑:程序博客网 时间:2024/05/24 04:33
关联到mysql数据库的爬虫,官方给的模板代码是
import pymysql
conn = pymysql.connect(host='127.0.0.1',unix_socekt='/tmp/mysql.sock',user='root',passwd=None,db='mysql')
cur = conn.cursor()
cur.execute("USE scraping")
conn = pymysql.connect(host='127.0.0.1',unix_socekt='/tmp/mysql.sock',user='root',passwd=None,db='mysql')
cur = conn.cursor()
cur.execute("USE scraping")
cur.execute("SELECT * FROM pages WHERE id=3")
print(cur.fetchone())
cur.close()
conn.close()
print(cur.fetchone())
cur.close()
conn.close()
试运行后报错TypeError: __init__() got an unexpected keyword argument 'unix_socekt'(没有unix_socket关键字)
于是将unix_socekt='/tmp/mysql.sock'改成port=3306成功通过并且实现了打印功能。
0 0
- python爬虫-->爬虫基础
- [爬虫] Python爬虫技巧
- Python爬虫
- python 爬虫
- python 爬虫
- python 爬虫
- python爬虫
- Python爬虫
- Python爬虫
- python 爬虫
- Python爬虫
- python爬虫
- python 爬虫
- python 爬虫
- python爬虫
- python爬虫
- python爬虫
- python 爬虫
- Hibernate通过Bean生成表的方法
- 编程技巧,数组覆盖
- 求n!的位数以及求n!具体的值(C or C++)
- 有向图强连通判断C/C++
- 排序算法c/c++
- python爬虫
- ext4_register_li_request
- Servlet的地址,跳转
- 查找元素出现的位置
- JSP内置对象(隐含对象)
- HDU2675
- CSS实现多列自适应布局
- 元编程初探
- Linux下Redis的安装和使用