在Perl进行爬网期间,MySQL服务器已消失 [英] MySQL server has gone away during crawling in Perl
问题描述
我使用WWW :: Mechanize库获取URL的内容并将其数据保存到mysql表中.但是,如果页面的内容太大,则会显示以下错误消息:
I use WWW::Mechanize library to get the content of URLs and save their data into mysql tables. But when the page's content is too large, it gives this error message:
DBD :: mysql :: st执行失败:MySQL服务器消失了 F:\ crawling \ perl_tests \ swc2.pl第481行.
DBD::mysql::st execute failed: MySQL server has gone away at F:\crawling\perl_tests\swc2.pl line 481.
例如,当我尝试提取此页面的内容时,它将引发此错误: https://www.e-conomic.com/secure/api1/EconomicWebService.asmx?wsdl
For example, it throws this error when I try to extract the content of this page: https://www.e-conomic.com/secure/api1/EconomicWebService.asmx?wsdl
我也添加了此代码,但仍然无法正常工作
I added this code as well, but it still does not work
$connection->{max_allowed_packet}=1000000000;
推荐答案
您是否正在使用最新的DBI和DBD :: mysql?它应该启用了mysql_auto_reconnect.
Are you using the latest DBI and DBD::mysql? It should have mysql_auto_reconnect enabled.
如果在分叉下使用mysql,则可能需要设置
If you're using mysql under forks, you may need to set
$dbh->{InactiveDestroy} = 1;
这篇关于在Perl进行爬网期间,MySQL服务器已消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!