mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-23 15:06:53 +00:00
Add proxy support to curl wrapper, provide proxy list from
http://multiproxy.org/txt_all/proxy.txt
This commit is contained in:
parent
701ea934a6
commit
8658d93ec5
@ -101,7 +101,7 @@ class FacebookBridge extends BridgeAbstract {
|
||||
$context = stream_context_create($http_options);
|
||||
$html = getContents($captcha_action, false, $context);
|
||||
*/
|
||||
list($html, $info, $res_header) = curlgetContents($captcha_action, $captcha_fields, true);
|
||||
list($html, $info, $res_header, $proxy) = curlgetContents($captcha_action, $captcha_fields, true);
|
||||
if ( $info['http_code'] != 200 )
|
||||
returnServerError('Error '.$info['http_code'].$captcha_action."\nReq:\n".$res_header."\nResp:\n".$info['request_header']);
|
||||
|
||||
@ -113,10 +113,11 @@ class FacebookBridge extends BridgeAbstract {
|
||||
}
|
||||
|
||||
$res_header = '';
|
||||
$proxy = '';
|
||||
//Retrieve page contents
|
||||
if (is_null($html)) {
|
||||
if (!strpos($this->getInput('u'), "/")) {
|
||||
list($html, $info, $res_header) = curlgetSimpleHTMLDOM(self::URI.urlencode($this->getInput('u')).'?_fb_noscript=1');
|
||||
list($html, $info, $res_header, $proxy) = curlgetSimpleHTMLDOM(self::URI.urlencode($this->getInput('u')).'?_fb_noscript=1');
|
||||
if ( $info['http_code'] != 200 )
|
||||
returnServerError('Error '.$info['http_code']."\nResp:\n".$res_header."\nReq:\n".$info['request_header']);
|
||||
} else {
|
||||
@ -151,6 +152,7 @@ class FacebookBridge extends BridgeAbstract {
|
||||
<p><b>Response:</b> <input name="captcha_response" placeholder="please fill in" />
|
||||
<input type="submit" value="Submit!" /></p>
|
||||
<pre>{$res_header}</pre>
|
||||
<p>Proxy: <pre>{$proxy}</pre></p>
|
||||
</form>
|
||||
EOD;
|
||||
die($message);
|
||||
|
@ -4,8 +4,16 @@ function curlgetContents( $url, $params, $post=false){
|
||||
curl_setopt($ch, CURLOPT_URL, $post ? $url : $url.'?'.http_build_query($params) );
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
|
||||
curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp/rssbridge-fb-cookies.txt');
|
||||
curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/rssbridge-fb-cookies.txt');
|
||||
#curl_setopt($ch, CURLOPT_COOKIEJAR, '/tmp/rssbridge-fb-cookies.txt');
|
||||
#curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp/rssbridge-fb-cookies.txt');
|
||||
$files = array_diff(scandir(__DIR__.'/../proxylist/'), array('.', '..'));
|
||||
$proxies = [];
|
||||
foreach($files as $file) {
|
||||
$proxies_str = file_get_contents(__DIR__.'/../proxylist/'.$file);
|
||||
array_push($proxies, explode("\n", $proxies_str));
|
||||
}
|
||||
$proxy = array_rand($proxies);
|
||||
curl_setopt($ch, CURLOPT_PROXY, $proxy);
|
||||
|
||||
curl_setopt($ch, CURLOPT_HEADER, 1);
|
||||
curl_setopt($ch, CURLOPT_VERBOSE, 1);
|
||||
@ -33,7 +41,7 @@ function curlgetContents( $url, $params, $post=false){
|
||||
curl_close($ch);
|
||||
file_put_contents(__DIR__.'/../debug/D'.date('H-i-s').'.html', $body);
|
||||
|
||||
return array($body, $info, $header);
|
||||
return array($body, $info, $header, $proxy);
|
||||
|
||||
}
|
||||
function curlgetSimpleHTMLDOM($url
|
||||
@ -48,7 +56,7 @@ function curlgetSimpleHTMLDOM($url
|
||||
, $defaultBRText = DEFAULT_BR_TEXT
|
||||
, $defaultSpanText = DEFAULT_SPAN_TEXT
|
||||
){
|
||||
list($body, $info, $header) = curlgetContents($url, $use_include_path, $context, $offset, $maxLen);
|
||||
list($body, $info, $header, $proxy) = curlgetContents($url, $use_include_path, $context, $offset, $maxLen);
|
||||
return array(str_get_html($body
|
||||
, $lowercase
|
||||
, $forceTagsClosed
|
||||
@ -56,6 +64,6 @@ function curlgetSimpleHTMLDOM($url
|
||||
, $stripRN
|
||||
, $defaultBRText
|
||||
, $defaultSpanText),
|
||||
$info, $header);
|
||||
$info, $header, $proxy);
|
||||
}
|
||||
?>
|
||||
|
0
proxylist/.gitkeep
Normal file
0
proxylist/.gitkeep
Normal file
1527
proxylist/proxy2.txt
Normal file
1527
proxylist/proxy2.txt
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user