szbhzc szbhzc
关注数: 23 粉丝数: 76 发帖数: 1,092 关注贴吧数: 5
php curl get 无法抓取淘宝搜索页面,麻烦大家了。 看到本吧里有人发了这个问题了。 链接在这里: http://tieba.baidu.com/p/3381012362 php 使用crul 如何抓取淘宝商品页面? 测试了几次都没有成功。同样的代码,可以抓取其它购物网站的商品页面,看来淘宝页面是做了手脚了。 也百度了一些答案,但没有帮助。 例子代码如下: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://tieba.baidu.com/mo/q/checkurl?url=https%3A%2F%2Fitem.taobao.com%2Fitem.htm%3Fspm%3Da230r.1.14.71.sEtvGB%26id%3D521435287162%26ns%3D1%26abbucket%3D4%23detail&urlrefer=cc35d9b04d04cd9e0938cc2f0a325bd2"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); $header[] = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"; $header[] = "Accept-Encoding: gzip, deflate"; $header[] = "Accept-Language: zh-CN"; $header[] = "Cache-Control: max-age=0"; $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7"; $header[] = "Connection: keep-alive"; //$header[] = "Accept-Language: zh-CN,zh;q=0.8,en;q=0.6"; //$header[] = "Cookie: isg=73B0849074EA7F14942163BAED489E51; l=ApCQTfqzJ17Da/gXOlHaSen3INDiEnSj; t=a504d557250dd67bd35762768dbc57e1; cna=LPwaDSEZwR8CATr67ElFiZp9; mt=ci%3D-1_0; thw=cn; v=0; cookie2=1ccaac47c99e290a183da147366f2630"; curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36'); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); //curl_setopt($ch, CURLOPT_HTTPHEADER, $header);//根据百度的结果,有人提到需要配置cookie,所以用httpwatch工具得到了GET淘宝页面时COOKIE的内容,从而构造了上面的那个cookie,但发现还是不能抓取呀,所以注释了这行; $output = curl_exec($ch); curl_close($ch); 根据百度的结果,有人提到需要配置cookie,所以用httpwatch工具得到了GET淘宝页面时COOKIE的内容,从而构造了上面的那个cookie,但发现还是不能抓取呀;
【转】树莓派TFT2.8寸 电阻式触摸屏 使用教学(支持B+的更新教程) 因为有些朋友总是问这个屏的教程,所以给朋友们转发一下,另外,请实践过的朋友指正一下。 ---------开始了---------------------------------------------------------------------------------------- 注意:2014-06-20-wheezy-raspbian.zip已完美解决,背光控制问题。并且B和B+版本都能通用,所以今天在更新一下驱动。 注意:2014-01的驱动打入 2014-06-20上,会有固件不兼容情况。所以大家严格按照本文最新版本制作就不会遇到奇怪的问题了! 软件安装步骤: 由于B+,需要最新的2014-06-20-wheezy-raspbian.zip系统,所以本文都是基于2014-06-20-wheezy-raspbian.zip上驱动。 1.下载内核补丁,并打入补丁 cd ~ wget http://tieba.baidu.com/mo/q/checkurl?url=http%3A%2F%2Fadafruit-download.s3.amazonaws.com%2Flibraspberrypi-bin-adafruit.deb&urlrefer=677c087130e0b831a7058feba342d401 wget http://tieba.baidu.com/mo/q/checkurl?url=http%3A%2F%2Fadafruit-download.s3.amazonaws.com%2Flibraspberrypi-dev-adafruit.deb&urlrefer=b5e961f58a3f0eae661a2391c11d345e wget http://tieba.baidu.com/mo/q/checkurl?url=http%3A%2F%2Fadafruit-download.s3.amazonaws.com%2Flibraspberrypi-doc-adafruit.deb&urlrefer=fa6d35cf078ba200f89ae328205565d9 wget http://tieba.baidu.com/mo/q/checkurl?url=http%3A%2F%2Fadafruit-download.s3.amazonaws.com%2Flibraspberrypi0-adafruit.deb&urlrefer=cf4f013810d6f95ac8e456d985806db5 wget http://tieba.baidu.com/mo/q/checkurl?url=http%3A%2F%2Fadafruit-download.s3.amazonaws.com%2Fraspberrypi-bootloader-adafruit-20140724-1.deb&urlrefer=15666587d5bf0c9c191badb8454c1ea0 //或者用sftp的方式下载到/home/pi/目录下 sudo dpkg -i -B *.deb //用2014-01-07-wheezy-raspbian.zip系统,注意下面移动的步骤这一步一定要做,不做无显示(非常容易忘记的一步)。 sudo mv /usr/share/X11/xorg.conf.d/99-fbturbo.conf ~ sudo reboot 2.安装、测试tft驱动 (触摸下面在测) sudo modprobe spi-bcm2708 sudo modprobe fbtft_device name=adafruitts rotate=90 export FRAMEBUFFER=/dev/fb1 startx 屏幕正常显示。触摸不准需要进一步矫正 3.显示驱动自动加载 sudo nano /etc/modules //增加一下2行 spi-bcm2708 fbtft_device sudo nano /etc/modprobe.d/adafruit.conf options fbtft_device name=adafruitts rotate=90 frequency=32000000 sudo mkdir /etc/X11/xorg.conf.d sudo nano /etc/X11/xorg.conf.d/99-calibration.conf //写入如下内容 Section "InputClass" Identifier "calibration" MatchProduct "stmpe-ts" Option "Calibration" "3800 200 200 3800" Option "SwapAxes" "1" EndSection //然后命令行打入 FRAMEBUFFER=/dev/fb1 startx sudo nano ~/.profile //在文件最后添加 export FRAMEBUFFER=/dev/fb1 sudo reboot 以后进入系统,在命令行下直接输入startx就可以在2.8寸液晶下显示内容了 4.矫正 触摸 sudo nano /etc/udev/rules.d/95-stmpe.rules //新加入如下内容 SUBSYSTEM=="input", ATTRS{name}=="stmpe-ts", ENV{DEVNAME}=="*event*", SYMLINK+="input/touchscreen" //重新加载驱动 sudo rmmod stmpe_ts; sudo modprobe stmpe_ts //查看会出现event(x)的事件,这句可做可不做 ls -l /dev/input/touchscreen //安装矫正的程序 sudo apt-get install evtest tslib libts-bin //这里直接直接测试触摸硬件,系统打印坐标,ctrl+c结束(这步可做可不做) sudo evtest /dev/input/touchscreen //矫正开始 sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/touchscreen ts_calibrate //矫正测试,可以当画图板,画图形:) ctrl+c结束 sudo TSLIB_FBDEVICE=/dev/fb1 TSLIB_TSDEVICE=/dev/input/touchscreen ts_test 5.当终端显示器 sudo nano /boot/cmdline.txt //在rootwait 后面添加如下内容 fbcon=map:10 fbcon=font:VGA8x8 sudo dpkg-reconfigure console-setup UTF-8 -》Guess optimal character set -》Terminus-》6x12(framebuffer only) 以上字体比较适合2.8的tft 6.关闭屏幕保护 终端命令行模式下30分钟后,屏幕会全黑,系统内部执行了屏保程序,需要关闭它。 sudo nano /etc/kbd/config //把 BLANK_TIME=30 //变为: BLANK_TIME=0 7.显示图像 sudo apt-get install fbi wget http#://adafruit-download.s3.amazonaws.com/adapiluv320x240.jpg //提醒:注意把上面一行中http后的#要删除,因为贴吧显示有问题 sudo fbi -T 2 -d /dev/fb1 -noverbose -a adapiluv320x240.jpg //照片5 7.控制背光 sudo sh -c "echo 252 > /sys/class/gpio/export" sudo ls -l /sys/class/gpio sudo sh -c "echo *out* > /sys/class/gpio/gpio252/direction" sudo sh -c "echo *1* > /sys/class/gpio/gpio252/value" //注意:关背光后,液晶任何显示都看不到!用上面的指令恢复!!! sudo sh -c "echo *0* > /sys/class/gpio/gpio252/value" 8.开关机按钮控制 sudo nano /etc/modules //增加如下内容: rpi_power_switch sudo nano /etc/modprobe.d/adafruit.conf //增加下面内容,23号开关键就是最左侧的按钮 options rpi_power_switch gpio_pin=23 mode=0 sudo modprobe rpi_power_switch 9. 播放动画 (mplayer服务器最近不稳定,可能会遇到404错误无法安装,此时需要换时间段下载,或者爬墙出去) ///////////////////////////////////// 题外知识,清华源加入树莓派 sudo su //备份【源网址文件】 cp /etc/apt/sources.list /etc/apt/sources.list.orig nano /etc/apt/sources.list //修改中间的国外网址为清华的网址 http://tieba.baidu.com/mo/q/checkurl?url=http%3A%2F%2Fmirrors.tuna.tsinghua.edu.cn%2Fraspbian%2Fraspbian%2F&urlrefer=f391b05b0a6304ca5f5376b70b352749 //如果清华mirror挂了,换 sg的:http://tieba.baidu.com/mo/q/checkurl?url=http%3A%2F%2Fmirror.nus.edu.sg%2Fraspbian%2Fraspbian&urlrefer=cb155e11e4b16061d226c4e0dfd0b17f //更新源地址后,同步系统软件库 apt-get update ///////////////////////////////////// sudo apt-get install mplayer wget http://tieba.baidu.com/mo/q/checkurl?url=http%3A%2F%2Fadafruit-download.s3.amazonaws.com%2Fbigbuckbunny320p.mp4&urlrefer=bdc1bbb3ef6f30de998a4950bd4f7212 mplayer -vo fbdev2:/dev/fb1 -x 240 -y 320 -framedrop bigbuckbunny320p.mp4 本文英文版本教程参考: http://tieba.baidu.com/mo/q/checkurl?url=http%3A%2F%2Flearn.adafruit.com%2Fadafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi%3Fview%3Dall&urlrefer=4dd4a6d08d58e0abd3ea820f72f35087
1 下一页