小编ale*_*kwa的帖子

如何使用代理运行本地PHP简单HTML DOM解析器?

我在MAMP本地有一个PHP Simple HTML DOM Parser,因为我位于日本,它可以提取信息并与日本版网站很好地配合使用.但是,我想从该网站的英国版本中提取信息.最简单的方法是什么?

我从文档中尝试了以下内容,但它不起作用.

$context = array('http' => array('proxy' => '212.82.126.32:80','request_fulluri' => true,),);
$stream = stream_context_create($context);

$html = file_get_html('http://www.supremenewyork.com/shop/new', false, $stream);
Run Code Online (Sandbox Code Playgroud)

由于网站启用了安全模式,我还尝试了修改后的curl版本.这不起作用.

function curl_exec_follow(/*resource*/ $ch, /*int*/ &$maxredirect = null) { 
    $mr = $maxredirect === null ? 5 : intval($maxredirect); 
    if (ini_get('open_basedir') == '' && ini_get('safe_mode' == 'Off')) { 
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $mr > 0); 
        curl_setopt($ch, CURLOPT_MAXREDIRS, $mr); 
    } else { 
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false); 
        if ($mr > 0) { 
            $newurl = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); 

            $rch = curl_copy_handle($ch); 
            curl_setopt($rch, CURLOPT_HEADER, true); 
            curl_setopt($rch, …
Run Code Online (Sandbox Code Playgroud)

php proxy curl simple-html-dom proxylocal

7
推荐指数
1
解决办法
1546
查看次数

如何使用函数参数作为变量的一部分?

这有效

chrome.storage.local.get('sizePref', function(items) { // Get size preferences from storage
  var sizePref2 = items.sizePref.tops; // Set size to a var
  console.log("You can get this " + sizePref2)
});
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试使它成为一个功能

function getSize(itemSize) {
  chrome.storage.local.get('sizePref', function(items) { // Get size preferences from storage
    var sizePref = items.sizePref.itemSize;
    return (sizePref);
  });
}
var mySize = getSize(tops);
console.log("This size that u are looking for is " + mySize)
Run Code Online (Sandbox Code Playgroud)

它说"上衣"是不确定的.

javascript variables function google-chrome-extension

1
推荐指数
1
解决办法
68
查看次数