jkphl / micrometa

A meta parser for extracting micro information out of web documents, currently supporting Microformats 1+2, HTML Microdata, RDFa Lite 1.1, JSON-LD and Link Types, written in PHP
http://micrometa.jkphl.is
MIT License
115 stars 39 forks source link

Is there anyway to set proxy? #33

Closed jslim89 closed 5 years ago

jslim89 commented 5 years ago

My server IP are blocked by some sites,

curl_setopt($ch, CURLOPT_PROXY, 'http://proxy-server.tld:12345');
curl_setopt($ch, CURLOPT_PROXYUSERPWD, 'mypass');

Is there anyway to set this option? #

jslim89 commented 5 years ago

I found a way to add proxy

$options = [                                                                    
    'client'  => [                                                              
        'timeout' => 30,                                                        
        'curl' => [                                                             
            CURLOPT_PROXY => 'http://proxy-server.tld:12345',                                                
            CURLOPT_PROXYUSERPWD => 'mypass',                                         
        ],                                                                      
    ],                                                                          
    'request' => [                                                              
        'verify'  => false,                                                     
        'headers' => [                                                          
        ]                                                                       
    ],                                                                          
];

$micrometa = new Parser();
$items     = $micrometa($url, null, FORMAT::ALL, $options);

Can be set in the options param

jkphl commented 5 years ago

@jslim89 You were faster than I could respond, but yes, this is what I would have suggested. Glad you could resolve it! :)