V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  bb2018  ›  全部回复第 1 页 / 共 4 页
回复总数  79
1  2  3  4  
还以亮一下不? 我也晒一下。  http://m.qqdo.com
2017-12-03 20:48:35 +08:00
回复了 oness 创建的主题 分享创造 一款全新的网页数据采集工具:爬山虎
同求个号体验 id 同名  bb2018
@shenhhd

还有一个问题是这三张表里的 id 都不是自增的。
看上面你写的视图没有 id 相关的, 在插入视图的时候怎么处理?就是 id 怎么赋值?
@shenhhd
这个思路是对的。但是我水平太低。最近正在补 mysql 的知识。看完教程再来试验一下结果。
@shenhhd

能说的明确一点不? 或者给个示例。谢谢。
@p2pCoder

这样不成功。
我用下面的方式:
sql = 'INSERT INTO `dede_archives` (typeid, title, pubdate, voteid, infourl, ) VALUES (%s, %s, %s, %s, %s)'
value = (item['infotypeid'], item['infotitle'], item['addtime'], 0, item['infourl'])
conn.execute(sql, value)
sql = 'INSERT INTO `dede_addonarticle` (aid, body) VALUES (%s, %s)'
value = (item['infotypeid'], item['infocontent'], )
conn.execute(sql, value)

可以插入数据库
但是那两个表各有一个 id 字段,不能设成自增的。
那空上 id 字段该怎么赋值呢?
2017-11-24 17:59:10 +08:00
回复了 mune 创建的主题 程序员 关于发展方向寻求一些大家的意见,求大家留情勿喷。
python
@p2pCoder
ok 多谢
晚上我测试一下试试。
@p2pCoder

try:
cursor.execute( 'INSERT INTO `phome_ecms_news` (classid, title, newstime) VALUES (%s, %s, %s)'value = (item['infotypeid'], item['infotitle'], item['addtime']))
cursor.execute('INSERT INTO `phome_ecms_news_data_1` (classid, newstext) VALUES (%s, %s)' value = (item['infotypeid'], item['infocontent']) )
cursor.execute('INSERT INTO `phome_ecms_news_index` (classid, newstime) VALUES (%s, %s)' value = (item['infotypeid'], iitem['addtime']) )
cursor.close()
conn.commit()
except Exception, e:
cursor.close()
conn.rollback()

这个样子差不多?
2017-11-24 14:33:42 +08:00
回复了 bb2018 创建的主题 Python windows2008 上要写一个自动执行 scrapy crawl xxx 的.bat 脚本
@JsClown
不明白激活虚拟环境?
我直接在 scrapy 目录里点击  xxx.bat 就可以运行  scrapy crawl abc 爬虫。
但是用 win 2008r2 的任务定时计划 就不行。一闪而过就不见了。那 cmd
@shenhhd
新手。不明白。什么视图?
@qiayue

sql = 'INSERT INTO `phome_ecms_news` (classid, title, newstime) VALUES (%s, %s, %s)'value = (item['infotypeid'], item['infotitle'], item['addtime'])
sql = 'INSERT INTO `phome_ecms_news_data_1` (classid, newstext) VALUES (%s, %s)' value = (item['infotypeid'], item['infocontent'])
sql = 'INSERT INTO `phome_ecms_news_index` (classid, newstime) VALUES (%s, %s)' value = (item['infotypeid'], iitem['addtime'])
conn.execute(sql, value)
@p2pCoder
sql = 'INSERT INTO `phome_ecms_news` (classid, title, newstime) VALUES (%s, %s, %s)'value = (item['infotypeid'], item['infotitle'], item['addtime'])
sql = 'INSERT INTO `phome_ecms_news_data_1` (classid, newstext) VALUES (%s, %s)' value = (item['infotypeid'], item['infocontent'])
sql = 'INSERT INTO `phome_ecms_news_index` (classid, newstime) VALUES (%s, %s)' value = (item['infotypeid'], iitem['addtime'])
conn.execute(sql, value)

这样子?
2017-11-15 22:08:00 +08:00
回复了 bb2018 创建的主题 Python windows2008 上要写一个自动执行 scrapy crawl xxx 的.bat 脚本
@enrolls 不明白。能说一下是什么意思不?
1  2  3  4  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   957 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 23ms · UTC 21:23 · PVG 05:23 · LAX 14:23 · JFK 17:23
Developed with CodeLauncher
♥ Do have faith in what you're doing.