PHP |如何在'content'=> http_build_query中发送网址?

时间:2018-01-12 10:43:59

标签: php

我试图在查询中发送URL,但是我收到错误:

  

语法错误,第7行意外'='

如何正确发送网址?

更新1:现在第8行出现问题

<?php
$opts = array(
'http'=>array(
'method'=>"POST",
'content'=>http_build_query("url=http://www.hotstar.com/tv/saath-nibhaana-saathiya/693/meera-humiliates-the-modis/1000055355")
'header'=>"User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:51.0) Gecko/20100101 Firefox/51.0" ,
      "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" ,
      "Cookie: __cfduid=d1d6556674ee5fe2038c6c516e6ad786f1515596203"
));
$context = stream_context_create($opts);
$url = "http://en.fetchfile.net/fetch/";
$data = file_get_contents($url, false, $context);
echo $data;

更新2: 我不知道为什么,但POST请求没有收到JSON

我正在尝试检查当前的问题,如有可能请求帮助谢谢

整个帖子请求:

User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:51.0) Gecko/20100101 Firefox/51.0
Accept: application/json, text/javascript, */*; q=0.01
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Requested-With: XMLHttpRequest
Referer: http://en.fetchfile.net/?url=http%3A%2F%2Fwww.hotstar.com%2Ftv%2Fsaath-nibhaana-saathiya%2F693%2Fahemgopi-have-a-fight%2F1000055779
Content-Length: 122
Cookie: __cfduid=d1d6556674ee5fe2038c6c516e6ad786f1515596203; _ym_uid=1515754827599813582; _ym_isad=2; bv_DSKskdck_s1d=bvDSKskdcks1d;  CoinHiveOptOut=1515754855.247; bvppvarnp0=1
Connection: keep-alive

体:

url=http%3A%2F%2Fwww.hotstar.com%2Ftv%2Fsaath-nibhaana-saathiya%2F693%2Fahemgopi-have-a-fight%2F1000055779&action=homePure

JSON响应:

{"acodec":"mp4a.40.2","description":"Meera humiliates Gopi at the Modi Bhavan. Later, Kinjal gets suspicious seeing Kokila's behaviour. Ahem is furious at Gopi for using his shirt as a cleaning cloth. Gopi reacts to his accusations. Later, Meera hurts Molu's head and humiliates Paridhi for playing a prank on her.","display_id":"1000055779","duration":1296,"episode":"Ahem-Gopi have a fight","episode_number":1369,"ext":"mp4","extractor":"HotStar","extractor_key":"HotStar","format":"hls-4563 - 1920x1080","format_id":"hls-4563","formats":[{"acodec":"mp4a.40.2","ext":"mp4","format":"hls-64 - 250x140","format_id":"hls-64","fps":null,"height":140,"http_headers":{"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","Accept-Charset":"ISO-8859-1,utf-8;q=0.7,*;q=0.7","Accept-Encoding":"gzip, deflate","Accept-Language":"en-us,en;q=0.5","Cookie":"_alid_=Q7nfOk5ehqKpd9pOQBAIiQ==; hdntl=exp=1515843396~acl=%2f*~data=hdntl~hmac=f1a825da0313c89669ed8f19155bf8410b9f1f6f39068ee04279dd22e7c4e78d","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/47.0 (Chrome)","X-Forwarded-For":"117.200.190.41"},"manifest_url":"https://staragvod1-vh.akamaihd.net/i/videos/plus/sns/1369/1000055779_,16,54,106,180,400,800,1300,2000,3000,4500,_STAR.mp4.csmil/master.m3u8?hdnea=st=1515756695~exp=1515757295~acl=/*~hmac=a524380edf50b440821777604ba55f39e4b12b45212be67d878ad7299ec4402f","preference":null,"protocol":"m3u8","tbr":64.0,"url":"https://staragvod1-vh.akamaihd.net/i/videos/plus/sns/1369/1000055779_,16,54,106,180,400,800,1300,2000,3000,4500,_STAR.mp4.csmil/index_1_av.m3u8?null=0&id=AgDUL+9aAhYWjMSdWFr0pI0ySbRDIOcQ+v8AA5I0zbQ0kTxVW6Fk8MREQkUs6kKfbBZtynevwukFzQ%3d%3d","vcodec":"avc1.66.30","width":250},{"acodec":"mp4a.40.2","ext":"mp4","format":"hls-121 - 320x180","format_id":"hls-121","fps":null,"height":180,"http_headers":{"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","Accept-Charset":"ISO-8859-1,utf-8;q=0.7,*;q=0.7","Accept-Encoding":"gzip, deflate","Accept-Language":"en-us,en;q=0.5","Cookie":"_alid_=Q7nfOk5ehqKpd9pOQBAIiQ==; hdntl=exp=1515843396~acl=%2f*~data=hdntl~hmac=f1a825da0313c89669ed8f19155bf8410b9f1f6f39068ee04279dd22e7c4e78d","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/47.0 (Chrome)","X-Forwarded-For":"117.200.190.41"},"manifest_url":"https://staragvod1-vh.akamaihd.net/i/videos/plus/sns/1369/1000055779_,16,54,106,180,400,800,1300,2000,3000,4500,_STAR.mp4.csmil/master.m3u8?hdnea=st=1515756695~exp=1515757295~acl=/*~hmac=a524380edf50b440821777604ba55f39e4b12b45212be67d878ad7299ec4402f","preference":null,"protocol":"m3u8","tbr":121.0,"url":"https://staragvod1-vh.akamaihd.net/i/videos/plus/sns/1369/1000055779_,16,54,106,180,400,800,1300,2000,3000,4500,_STAR.mp4.csmil/index_2_av.m3u8?null=0&id=AgDUL+9aAhYWjMSdWFr0pI0ySbRDIOcQ+v8AA5I0zbQ0kTxVW6Fk8MREQkUs6kKfbBZtynevwukFzQ%3d%3d","vcodec":"avc1.66.30","width":320},{"acodec":"mp4a.40.2","ext":"mp4","format":"hls-241 - 320x180","format_id":"hls-241","fps":null,"height":180,"http_headers":{"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","Accept-Charset":"ISO-8859-1,utf-8;q=0.7,*;q=0.7","Accept-Encoding":"gzip, deflate","Accept-Language":"en-us,en;q=0.5","Cookie":"_alid_=Q7nfOk5ehqKpd9pOQBAIiQ==; hdntl=exp=1515843396~acl=%2f*~data=hdntl~hmac=f1a825da0313c89669ed8f19155bf8410b9f1f6f39068ee04279dd22e7c4e78d","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/47.0 (Chrome)","X-Forwarded-For":"117.200.190.41"},"manifest_url":"https://staragvod1-vh.akamaihd.net/i/videos/plus/sns/1369/1000055779_,16,54,106,180,400,800,1300,2000,3000,4500,_STAR.mp4.csmil/master.m3u8?hdnea=st=1515756695~exp=1515757295~acl=/*~hmac=a524380edf50b440821777604ba55f39e4b12b45212be67d878ad7299ec4402f","preference":null,"protocol":"m3u8","tbr":241.0,"url":"https://staragvod1-vh.akamaihd.net/i/videos/plus/sns/1369/1000055779_,16,54,106,180,400,800,1300,2000,3000,4500,_STAR.mp4.csmil/index_3_av.m3u8?null=0&id=AgDUL+9aAhYWjMSdWFr0pI0ySbRDIOcQ+v8AA5I0zbQ0kTxVW6Fk8MREQkUs6kKfbBZtynevwukFzQ%3d%3d","vcodec":"avc1.66.30","width":320},{"acodec":"mp4a.40.2","ext":"mp4","format":"hls-461 - 416x234","format_id":"hls-461","fps":null,"height":234,"http_headers":{"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","Accept-Charset":"ISO-8859-1,utf-8;q=0.7,*;q=0.7","Accept-Encoding":"gzip, deflate","Accept-Language":"en-us,en;q=0.5","Cookie":"_alid_=Q7nfOk5ehqKpd9pOQBAIiQ==; hdntl=exp=1515843396~acl=%2f*~data=hdntl~hmac=f1a825da0313c89669ed8f19155bf8410b9f1f6f39068ee04279dd22e7c4e78d","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/47.0 (Chrome)","X-Forwarded-For":"117.200.190.41"},"manifest_url":"https://staragvod1-vh.akamaihd.net/i/videos/plus/sns/1369/1000055779_,16,54,106,180,400,800,1300,2000,3000,4500,_STAR.mp4.csmil/master.m3u8?hdnea=st=1515756695~exp=1515757295~acl=/*~hmac=a524380edf50b440821777604ba55f39e4b12b45212be67d878ad7299ec4402f","preference":null,"protocol":"m3u8","tbr":461.0,"url":"https://staragvod1-vh.akamaihd.net/i/videos/plus/sns/1369/1000055779_,16,54,106,180,400,800,1300,2000,3000,4500,_STAR.mp4.csmil/index_4_av.m3u8?null=0&id=AgDUL+9aAhYWjMSdWFr0pI0ySbRDIOcQ+v8AA5I0zbQ0kTxVW6Fk8MREQkUs6kKfbBZtynevwukFzQ%3d%3d","vcodec":"avc1.66.30","width":416},{"acodec":"mp4a.40.2","ext":"mp4","format":"hls-861 - 640x360","format_id":"hls-861","fps":null,"height":360,"http_headers":{"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","Accept-Charset":"ISO-8859-1,utf-8;q=0.7,*;q=0.7","Accept-Encoding":"gzip, deflate","Accept-Language":"en-us,en;q=0.5","Cookie":"_alid_=Q7nfOk5ehqKpd9pOQBAIiQ==; hdntl=exp=1515843396~acl=%2f*~data=hdntl~hmac=f1a825da0313c89669ed8f19155bf8410b9f1f6f39068ee04279dd22e7c4e78d","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/47.0 (Chrome)","X-Forwarded-For":"117.200.190.41"},"manifest_url":"https://staragvod1-vh.akamaihd.net/i/videos/plus/sns/1369/1000055779_,16,54,106,180,400,800,1300,2000,3000,4500,_STAR.mp4.csmil/master.m3u8?hdnea=st=1515756695~exp=1515757295~acl=/*~hmac=a524380edf50b440821777604ba55f39e4b12b45212be67d878ad7299ec4402f","preference":null,"protocol":"m3u8","tbr":861.0,"url":"https://staragvod1-vh.akamaihd.net/i/videos/plus/sns/1369/1000055779_,16,54,106,180,400,800,1300,2000,3000,4500,_STAR.mp4.csmil/index_5_av.m3u8?null=0&id=AgDUL+9aAhYWjMSdWFr0pI0ySbRDIOcQ+v8AA5I0zbQ0kTxVW6Fk8MREQkUs6kKfbBZtynevwukFzQ%3d%3d","vcodec":"avc1.66.30","width":640},{"acodec":"mp4a.40.2","ext":"mp4","format":"hls-1360 - 720x404","format_id":"hls-1360","fps":null,"height":404,"http_headers":{"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","Accept-Charset":"ISO-8859-1,utf-8;q=0.7,*;q=0.7","Accept-Encoding":"gzip, deflate","Accept-Language":"en-us,en;q=0.5","Cookie":"_alid_=Q7nfOk5ehqKpd9pOQBAIiQ==; hdntl=exp=1515843396~acl=%2f*~data=hdntl~hmac=f1a825da0313c89669ed8f19155bf8410b9f1f6f39068ee04279dd22e7c4e78d","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/47.0 (Chrome)","X-Forwarded-For":"117.200.190.41"},"manifest_url":"https://staragvod1-vh.akamaihd.net/i/videos/plus/sns/1369/1000055779_,16,54,106,180,400,800,1300,2000,3000,4500,_STAR.mp4.csmil/master.m3u8?hdnea=st=1515756695~exp=1515757295~acl=/*~hmac=a524380edf50b440821777604ba55f39e4b12b45212be67d878ad7299ec4402f","preference":null,"protocol":"m3u8","tbr":1360.0,"url":"https://staragvod1-vh.akamaihd.net/i/videos/plus/sns/1369/1000055779_,16,54,106,180,400,800,1300,2000,3000,4500,_STAR.mp4.csmil/index_6_av.m3u8?null=0&id=AgDUL+9aAhYWjMSdWFr0pI0ySbRDIOcQ+v8AA5I0zbQ0kTxVW6Fk8MREQkUs6kKfbBZtynevwukFzQ%3d%3d","vcodec":"avc1.66.30","width":720},{"acodec":"mp4a.40.2","ext":"mp4","format":"hls-2062 - 1280x720","format_id":"hls-2062","fps":null,"height":720,"http_headers":{"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","Accept-Charset":"ISO-8859-1,utf-8;q=0.7,*;q=0.7","Accept-Encoding":"gzip, deflate","Accept-Language":"en-us,en;q=0.5","Cookie":"_alid_=Q7nfOk5ehqKpd9pOQBAIiQ==; hdntl=exp=1515843396~acl=%2f*~data=hdntl~hmac=f1a825da0313c89669ed8f19155bf8410b9f1f6f39068ee04279dd22e7c4e78d","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/47.0 (Chrome)","X-Forwarded-For":"117.200.190.41"},"manifest_url":"https://staragvod1-vh.akamaihd.net/i/videos/plus/sns/1369/1000055779_,16,54,106,180,400,800,1300,2000,3000,4500,_STAR.mp4.csmil/master.m3u8?hdnea=st=1515756695~exp=1515757295~acl=/*~hmac=a524380edf50b440821777604ba55f39e4b12b45212be67d878ad7299ec4402f","preference":null,"protocol":"m3u8","tbr":2062.0,"url":"https://staragvod1-vh.akamaihd.net/i/videos/plus/sns/1369/1000055779_,16,54,106,180,400,800,1300,2000,3000,4500,_STAR.mp4.csmil/index_7_av.m3u8?null=0&id=AgDUL+9aAhYWjMSdWFr0pI0ySbRDIOcQ+v8AA5I0zbQ0kTxVW6Fk8MREQkUs6kKfbBZtynevwukFzQ%3d%3d","vcodec":"avc1.77.30","width":1280},{"acodec":"mp4a.40.2","ext":"mp4","format":"hls-3062 - 1600x900","format_id":"hls-3062","fps":null,"height":900,"http_headers":{"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","Accept-Charset":"ISO-8859-1,utf-8;q=0.7,*;q=0.7","Accept-Encoding":"gzip, deflate","Accept-Language":"en-us,en;q=0.5","Cookie":"_alid_=Q7nfOk5ehqKpd9pOQBAIiQ==; hdntl=exp=1515843396~acl=%2f*~data=hdntl~hmac=f1a825da0313c89669ed8f19155bf8410b9f1f6f39068ee04279dd22e7c4e78d","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/47.0 (Chrome)","X-Forwarded-For":"117.200.190.41"},"manifest_url":"https://staragvod1-vh.akamaihd.net/i/videos/plus/sns/1369/1000055779_,16,54,106,180,400,800,1300,2000,3000,4500,_STAR.mp4.csmil/master.m3u8?hdnea=st=1515756695~exp=1515757295~acl=/*~hmac=a524380edf50b440821777604ba55f39e4b12b45212be67d878ad7299ec4402f","preference":null,"protocol":"m3u8","tbr":3062.0,"url":"https://staragvod1-vh.akamaihd.net/i/videos/plus/sns/1369/1000055779_,16,54,106,180,400,800,1300,2000,3000,4500,_STAR.mp4.csmil/index_8_av.m3u8?null=0&id=AgDUL+9aAhYWjMSdWFr0pI0ySbRDIOcQ+v8AA5I0zbQ0kTxVW6Fk8MREQkUs6kKfbBZtynevwukFzQ%3d%3d","vcodec":"avc1.77.30","width":1600},{"acodec":"mp4a.40.2","ext":"mp4","format":"hls-4563 - 1920x1080","format_id":"hls-4563","fps":null,"height":1080,"http_headers":{"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","Accept-Charset":"ISO-8859-1,utf-8;q=0.7,*;q=0.7","Accept-Encoding":"gzip, deflate","Accept-Language":"en-us,en;q=0.5","Cookie":"_alid_=Q7nfOk5ehqKpd9pOQBAIiQ==; hdntl=exp=1515843396~acl=%2f*~data=hdntl~hmac=f1a825da0313c89669ed8f19155bf8410b9f1f6f39068ee04279dd22e7c4e78d","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/47.0 (Chrome)","X-Forwarded-For":"117.200.190.41"},"manifest_url":"https://staragvod1-vh.akamaihd.net/i/videos/plus/sns/1369/1000055779_,16,54,106,180,400,800,1300,2000,3000,4500,_STAR.mp4.csmil/master.m3u8?hdnea=st=1515756695~exp=1515757295~acl=/*~hmac=a524380edf50b440821777604ba55f39e4b12b45212be67d878ad7299ec4402f","preference":null,"protocol":"m3u8","tbr":4563.0,"url":"https://staragvod1-vh.akamaihd.net/i/videos/plus/sns/1369/1000055779_,16,54,106,180,400,800,1300,2000,3000,4500,_STAR.mp4.csmil/index_9_av.m3u8?null=0&id=AgDUL+9aAhYWjMSdWFr0pI0ySbRDIOcQ+v8AA5I0zbQ0kTxVW6Fk8MREQkUs6kKfbBZtynevwukFzQ%3d%3d","vcodec":"avc1.77.30","width":1920}],"fps":null,"height":1080,"http_headers":{"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8","Accept-Charset":"ISO-8859-1,utf-8;q=0.7,*;q=0.7","Accept-Encoding":"gzip, deflate","Accept-Language":"en-us,en;q=0.5","Cookie":"_alid_=Q7nfOk5ehqKpd9pOQBAIiQ==; hdntl=exp=1515843396~acl=%2f*~data=hdntl~hmac=f1a825da0313c89669ed8f19155bf8410b9f1f6f39068ee04279dd22e7c4e78d","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20150101 Firefox/47.0 (Chrome)","X-Forwarded-For":"117.200.190.41"},"id":"1000055779","manifest_url":"https://staragvod1-vh.akamaihd.net/i/videos/plus/sns/1369/1000055779_,16,54,106,180,400,800,1300,2000,3000,4500,_STAR.mp4.csmil/master.m3u8?hdnea=st=1515756695~exp=1515757295~acl=/*~hmac=a524380edf50b440821777604ba55f39e4b12b45212be67d878ad7299ec4402f","playlist":null,"playlist_index":null,"preference":null,"protocol":"m3u8","requested_subtitles":null,"series":"Saath Nibhaana Saathiya","tbr":4563.0,"timestamp":1428499800,"title":"Ahem-Gopi have a fight","upload_date":"20150408","url":"https://staragvod1-vh.akamaihd.net/i/videos/plus/sns/1369/1000055779_,16,54,106,180,400,800,1300,2000,3000,4500,_STAR.mp4.csmil/index_9_av.m3u8?null=0&id=AgDUL+9aAhYWjMSdWFr0pI0ySbRDIOcQ+v8AA5I0zbQ0kTxVW6Fk8MREQkUs6kKfbBZtynevwukFzQ%3d%3d","vcodec":"avc1.77.30","webpage_url":"http://www.hotstar.com/tv/saath-nibhaana-saathiya/693/ahemgopi-have-a-fight/1000055779","webpage_url_basename":"1000055779","width":1920}

Cookies有效期至2019年

我再次发送POST请求,我得到了fetchfile的HTML页面,而不是带有视频链接的JSON

1 个答案:

答案 0 :(得分:1)

你应该替换:

from apscheduler.schedulers.background import BackgroundScheduler


def job_function():
    print("Hello World")

sched = BackgroundScheduler()

sched.add_job(job_function, 'cron', hour='7-23', minute='*')

sched.start()

通过

http_build_query(url=http://www.hotstar.com/tv/saath-nibhaana-saathiya/693/meera-humiliates-the-modis/1000055355)