我正试图刮一个远程网站.我正在使用PHP Curl,我的代码很好.我知道因为我使用了Fiddler,Tamper Data等来使我的代码恰到好处.但是,它仍然无法正常工作.所以,我尝试了几个小时前我应该测试过的东西:
我在浏览器中关闭了cookie.果然,我现在无法搜索远程站点.他们的代码需要一个cookie来搜索我想要的产品.
有没有办法伪造/欺骗/规避所以我可以刮网站?我可以告诉CURL使用我下载的cookie吗?我甚至不知道要问的正确问题.
大家.
我正在使用CodeIgniter,我没有得到此查询的结果:
$this->load->database();
$this->db->select('*');
$this->db->from('users');
$this->db->join('show_guides', 'show_guides.user_id = users.user_id');
$this->db->where('users.user_id', $user_id['user_id'], 'left outer');
$query = $this->db->get();
foreach ($query->result_array() as $row) {
$results = $row;
}
Run Code Online (Sandbox Code Playgroud)
'users'表总是有结果,但有时用户在'show_guides'表中没有行.当'show_guides'表没有结果时,查询不会返回'users'表中的结果.
当'show_guides'没有产生结果时,$ row不存在.当两个表都包含匹配users.user_id的数据时,我才会得到结果.
有什么建议?
谢谢!
编辑 为避免任何混淆,此查询为我提供了我需要的结果,但我想使用CodeIgniter数据库对象.
SELECT u.*,s.*
FROM users u
LEFT OUTER JOIN show_guides s ON u.user_id = s.user_id
WHERE u.user_id = 155;
Run Code Online (Sandbox Code Playgroud)
即使show_guides为空,这也会产生结果.
我正在调用Amazon API来获取用于预订封面缩略图的URL.
缩略图网址如下:
\\ebc.amazon.com\images\EtcLkasff-_-23.jpg
Run Code Online (Sandbox Code Playgroud)
正斜杠是问题所在.要使这些图像显示在我的页面上,请将"\"替换为"/".但是,我的正则表达式php_replace语法失败了我.
我有这个:
$thumbnail = str_replace('\', '//', $apiString);
Run Code Online (Sandbox Code Playgroud)
我试过了
$thumbnail = str_replace('\\', '//', $apiString);
Run Code Online (Sandbox Code Playgroud)
它仍然无法正常工作.
在此先感谢大家!
编辑:::
在我做之后:
$thumbnail = "http://" . $thumbnail;
Run Code Online (Sandbox Code Playgroud)
URL如下所示:
http://\/\/ecx.images-amazon.com\/images\/I\/51vCLCTcmAL._SL75_.jpg
Run Code Online (Sandbox Code Playgroud)
我试过了
$picture4 = str_replace('\', '/', $picture4);
Run Code Online (Sandbox Code Playgroud)
这给了我一个逃避错误.
对不起:(还有一个编辑可以让事情变得非常清楚:
我这样做了:
// get amazon picture URL
$picture1 = preg_split('/,/', str_replace("\"", "", $details));
$picture2 = preg_split('/:/', $picture1[7]);
$picture3 = preg_replace('/\\//','/',$picture2[2]);
$picture4 = preg_replace('/\\//','/',$picture3);
// $picture4 = str_replace('\', '/', $picture4);
$picture4 = "http://" . $picture4;
echo "<pre>";print_r($picture4);echo "</pre>";
Run Code Online (Sandbox Code Playgroud)
此时,$ picture4是:
HTTP://\/\/ecx.images-amazon.com\/影像\/I\/ 51vCLCTcmAL.SL75 .jpg
我做了一张桌子:
+---------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+---------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| date | date | NO | | NULL | |
| user_id | int(8) | YES | | NULL | |
| isbn | varchar(13) | NO | | NULL | |
| price | decimal(6,2) | NO | | NULL | |
+---------+--------------+------+-----+---------+----------------+
Run Code Online (Sandbox Code Playgroud)
并且,日期colomn不起作用.我想我需要将表修改为默认为"CURDATE()".这就是我从谷歌上搜索到的.我甚至不确定这是不是问题,但我的修改声明不起作用.
我试图改变这个:
mysql> ALTER TABLE buybacks …Run Code Online (Sandbox Code Playgroud)