wkhtmltopdf没有为谷歌搜索提供准确的结果

时间:2012-11-26 14:58:45

标签: wkhtmltopdf google-search

wkhtmltopdf 没有提供谷歌搜索的确切pdf
wkhtmltopdf命令

wkhtmltopdf toc --javascript-delay 5000 --load-error-handling ignore "https://www.google.co.in/search?hl=en&safe=off&client=firefox-beta&hs=1re&tbo=d&rls=org.mozilla%3Aen-US%3Aofficial&channel=fflb&q=height+of+lionel+messi&oq=height+of+lionell&gs_l=serp.3.0.0i13l2j0i13i30.3477969.3479300.0.3480775.7.7.0.0.0.0.233.1161.2j1j4.7.0.les%3B..0.0...1c.1.8wCY6CBhpqY" google.pdf

尝试google search

1.69m 中未显示谷歌搜索框

2 个答案:

答案 0 :(得分:5)

我自己得到了答案,以防将来有人遇到同样的问题 问题是我没有发送'用户代理'

尝试

wkhtmltopdf --custom-header "User-Agent" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:14.0) Gecko/20100101 Firefox/14.0.1" --custom-header-propagation "https://www.google.co.in/search?hl=en&safe=off&client=firefox-beta&hs=1re&tbo=d&rls=org.mozilla%3Aen-US%3Aofficial&channel=fflb&q=height+of+lionel+messi&oq=height+of+lionell&gs_l=serp.3.0.0i13l2j0i13i30.3477969.3479300.0.3480775.7.7.0.0.0.0.233.1161.2j1j4.7.0.les%3B..0.0...1c.1.8wCY6CBhpqY" google.pdf

答案 1 :(得分:1)

尝试以下命令,它将生成桌面版:

wkhtmltopdf --viewport-size 1280x1024 --orientation Landscape http://site_name.com file_name.pdf