我正在抓取一个拥有Oracle ADF环回脚本的网站,该脚本不断将我重定向到我的同一页面,那么如何绕过它呢?
以下是我的PHP代码.
<?php
$url = 'https://www.mywebsite.com/faces/index.jspx';
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__) . '/cookie.txt');
curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__) . '/cookie.txt');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$header[] = 'User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$data = curl_exec($ch);
curl_close($ch);
if (curl_errno($ch)) { // check for execution errors
echo 'Scraper error: ' . curl_error($ch);
exit;
}
echo $data;
?>
Run Code Online (Sandbox Code Playgroud)
当我运行上面的代码时,我被重定向到同一页面,
它还添加了一些查询字符串参数,如 ?_afrLoop=39478247795404&_afrWindowMode=0&_afrWindowId=null
在实际的网站_afrWindowId有一些随机的字母数字字符串,但我得到了null. …
我是 python 新手,我正在运行程序,也许它是用我朋友提供的 python2.X 编写的,
但它没有运行,因为dict object has no attribute viewkeys当我运行脚本时,我收到了最初的错误,错误如下:
Traceback (most recent call last):
File "test.py", line 236, in <module>
for key in (Data_Pe.keys() | Data.viewkeys()):
AttributeError: 'dict' object has no attribute 'viewkeys'
Run Code Online (Sandbox Code Playgroud)
在其中Data_pe,Data两者都是dict对象。