出于某种原因,我似乎无法通过cURL获取此特定网页的内容.我已经设法使用cURL来获得"顶级页面"内容,但是相同的自建快速cURL功能似乎不适用于其中一个链接的子网页.
顶级页面: http://www.deindeal.ch/
子页面: http://www.deindeal.ch/deals/hotel-cristal-in-nuernberg-30/
我的cURL函数(在functions.php中)
function curl_get($url) {
$ch = curl_init();
$header = array(
'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-Language: en-us;q=0.8,en;q=0.6'
);
$options = array(
CURLOPT_URL => $url,
CURLOPT_HEADER => 0,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13',
CURLOPT_HTTPHEADER => $header
);
curl_setopt_array($ch, $options);
$return = curl_exec($ch);
curl_close($ch);
return $return;
}
Run Code Online (Sandbox Code Playgroud)
PHP文件获取内容(使用echo进行测试)
require "functions.php";
require "phpQuery.php";
echo curl_get('http://www.deindeal.ch/deals/hotel-walliserhof-zermatt-2-naechte-30/');
Run Code Online (Sandbox Code Playgroud)
到目前为止,我已尝试以下方法来实现此功能
curl_get()包含所有选项之前,除了CURLOPT_USERAGENT andCURLOPT_HTTPHEADERS`之外.是否有可能通过cURL或其他远程文件打开机制完全阻止请求,无论提供多少数据来尝试发出真正的浏览器请求?
此外,是否有可能诊断为什么我的请求没有出现?
任何帮助回答上述两个问题,或编辑/提出获取文件内容的建议,即使通过不同于cURL的方法,也将非常感谢;).
我有一个ID #navigation与position: relative;和它里面的一类.submenu带position:absolute;.子菜单包含文本(<a>更具体地说是标记链接),这些文本已经失去了它们的cursor: pointer;属性,并且在它们的帐户上被选中的能力现在位于页面上的其他元素之后.
这是一个链接,以便您可以实际看到我在说什么:
http://pixelation.me/show/stackoverflow/
我不知道我能做什么,没有声明#navigation和页面底部的所有孩子,以便.submenu"走到前面".
我已经尝试过设置z-index: 1; 在.submenu,这没用.
任何更多的建议/答案将不胜感激;)!
基本上,我想同时使用str_replace()$city_name和$ref_namestr_replace(),这样如果用户输入其中一个(或两个),它们都会被实际的变量形式替换.
为了更好地说明,这是我目前的代码;
$headlines = array('primary_headline' => $_POST['primary_headline'], 'secondary_headline' => $_POST['secondary_headline'], 'primary_subline' => $_POST['primary_subline'], 'secondary_subtext' => $_POST['secondary_subtext']);
$city_name = "Dallas";
$ref_name = "Facebook";
if(isset($headlines)) {
foreach($headlines as $headline) {
echo(str_replace('$city_name', $city_name, $headline));
}
}
Run Code Online (Sandbox Code Playgroud)
我基本上想str_replace('$city_name', $city_name, $headline)成为str_replace('$city_name' AND/OR '$ref_name', $city_name AND/OR $ref_name, $headline).
任何答案或评论将不胜感激!
只是一个抬头,我理解为什么会有一些规则反对允许这个功能,因为它会被假设,因为有人打开了大量的垃圾邮件弹出窗口的影响,但是,我想知道它是否在所有可能使它工作.
这是我的代码;
$(document).ready( function() {
("a.explode").load(
function() { var url = $(this).attr("href");
window.open(url); }
);
});
Run Code Online (Sandbox Code Playgroud)
和
<a class="explode" href="http://www.google.com">Link1</a>
<a class="explode" href="http://www.yahoo.com">Link2</a>
<a class="explode" href="http://www.tumblr.com">Link3</a>
Run Code Online (Sandbox Code Playgroud)
对于那些不明白我想要做什么的人,在页面加载时,使用href=""属性打开几个窗口<a class="explode">.
POST实验编辑:在与一个可爱的SO成员一起完成这项工作后,我们发现这不值得实现/不可能(由于大多数浏览器本身都有弹出窗口阻止程序).window.open()必须绑定到一个.click()事件,实际上使这个概念无用.
我通常var_dump()用来转储我的数组的内容,以便评估结构.然而,这变得乏味,因为更大的转储,信息在我的23"屏幕上传播,使得很难轻易地找出哪些关键匹配哪个值.
无论如何都要将数组的内容垂直转储,类似于PHP手册使用的方式:
Array
(
[a] => apple
[b] => banana
[c] => Array
(
[0] => x
[1] => y
[2] => z
)
)
Run Code Online (Sandbox Code Playgroud)
我真的很想知道,因为这会节省很多时间.
任何意见/建议/答案将不胜感激;)!!
我正在使用javascript的内置.test()函数来测试字符串或正则表达式是否匹配.我从RegexLib中获取了正则表达式,所以我知道它与它测试的字符串匹配(在这种情况下joe@aol.com),但它要么返回false,要么根本不返回.
这是我的代码:
var string = "joe@aol.com";
var pattern = [\w-]+@([\w-]+\.)+[\w-]+/i;
var match = pattern.test(string);
document.write(match);
Run Code Online (Sandbox Code Playgroud)
当正则表达式被引号括起来时,测试返回false,当它没有包含在任何内容中时,它什么都不返回.
到目前为止我尝试过的:
var match = '[\w-]+@([\w-]+\.)+[\w-]+/i'.test("joe@aol.com");.'单引号和"两个双引号regex和string./i和附加正则表达式/g.老实说,我不知道是什么导致了这个问题,所以任何帮助都会很棒.它可能是一个完整的新手错误,也许是一个被遗忘的语法.
这里有一个jsFiddle的链接,如果你认为你已经知道如何解决这个问题,我可以帮你解决这个问题:http://jsfiddle.net/wFhEJ/1/
我见过一对夫妇的其他职位上这里的问候jQuery的.css()不工作-webkit-gradient,但是我还没有找到一个有关-ms-linear-gradient,-o-linear-gradient和linear-gradient.
简而言之,我已经创建了一个函数,它#hex使用所有最流行的CSS属性来设置元素的基础背景渐变,以便直接从ColorZilla获取跨浏览器兼容性.
以下是我正在谈论的特定片段:
$(elem).css({
'background': b,
'background': '-moz-linear-gradient(top, '+a+' 0%, '+b+' 100%)',
'background': '-webkit-gradient(linear, left top, left bottom, color-stop(0%,'+a+'), color-stop(100%,'+b+'))',
'background': '-webkit-linear-gradient(top, '+a+' 0%,'+b+' 100%)',
'background': '-o-linear-gradient(top, '+a+' 0%,'+b+' 100%)', // Breaks execution
'background': '-ms-linear-gradient(top, '+a+' 0%,'+b+' 100%)', // Breaks execution
'background': 'linear-gradient(top, '+a+' 0%,'+b+' 100%)', // Breaks execution
'filter': 'progid:DXImageTransform.Microsoft.gradient( startColorstr=\''+a+'\', endColorstr=\''+b+'\',GradientType=0 )'
});
Run Code Online (Sandbox Code Playgroud)
我在//breaks execution每个属性旁边放置了一个注释,当活动时(集体或单独)破坏脚本的执行(没有设置其他属性,例如background: b(b当然是变量)).
我完全不知道为什么会这样.
到目前为止,我已经尝试过: …
这会产生某种永久循环吗?我已经尝试发布数据,并且页面根本不会加载,包含表单的页面只是在表单提交上"加载".
for($i = 1; $i = 5; $i++) {
$country[$i] = $_POST['country_'.$i];
$redirect[$i] = $_POST['redirect_'.$i];
}
var_dump($country);
var_dump($redirect);
Run Code Online (Sandbox Code Playgroud)
这是我的表格;
<form action="query.php" method="post" id="geoui">
<div id="input1" class="clonedInput">
<select name="country_1" class="px460s">
<option selected="selected" value="auto">Choose country to set rule for..</option>
<option>United Kingdom</option>
<option>Canada</option>
</select>
<input name="redirect_1" type="text" class="px460" value="http://">
<div class="break"></div>
</div><div id="input2" class="clonedInput">
<select name="country_2" class="px460s">
<option selected="selected" value="auto">Choose country to set rule for..</option>
<option>United Kingdom</option>
<option>Canada</option>
</select>
<input name="redirect_2" type="text" class="px460" value="http://">
<div class="break"></div>
</div><div id="input3" class="clonedInput">
<select name="country_3" class="px460s">
<option …Run Code Online (Sandbox Code Playgroud) 我一直试图在过去的五分钟内调试这个,我只是不知道问题是什么:
这是我的代码,第33-37行:
for($i = 0; $i < 5; $i++) {
$followers_change[$i] = $en_array1[$i]['followers']-$en_array2[$i]['followers'];
$rank_change[$i] = $en_array1[$i]['rank']-$en_array2[$i]['rank'];
echo "<tr><td>$en_array1[$i]['rank']</td><td><img src='$en_array1[$i]['imageurl']' width='48' height='48'/></td><td>$en_array1[$i]['name']</td><td>$en_array1[$i]['followers]'</td><td>$en_array1['followers_change']</td></tr>";
}
Run Code Online (Sandbox Code Playgroud)
我一直收到错误:
解析错误:语法错误,意外T_ENCAPSED_AND_WHITESPACE,期望在第36行的/.../中的T_STRING或T_VARIABLE或T_NUM_STRING
我为这是一个如此愚蠢/新秀的错误而道歉,我只是在同一时间感到难过(这不是一个很好的组合:)).
我想使用cURL创建一个函数,并使用bit.ly API来缩短链接.
我的问题是,如何获取cURL返回的数据字符串并继续在整个函数中使用它(因为这似乎不起作用,我假设由于尝试return $string然后在其余部分使用字符串功能).
这就是我所拥有的,它只显示一个空白页面:
function shorten_url($bit_login,$bit_api,$long_url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://api.bitly.com/v3/shorten?login=".$bit_login."&apiKey=".$bit_api."&longUrl=".$long_url."&format=xml");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
return $string;
$xml = simplexml_load_string($string);
$short_url = $xml->data[0]->url;
echo $short_url;
}
shorten_url($login,$apikey,"http://www.google.com");
Run Code Online (Sandbox Code Playgroud)
return $short_url在运行函数(下面shorten_url())之后,我也尝试并在函数的后面回显它,这也不起作用.
我正在尝试更改选项标题(.option-title)上显示的图标,当下面的内容(例如(.add_to_rotation)向上或向下切换时.向下时,.retract-icon应显示close()按钮,同时.expand-icon应显示add().
我认为的问题在于从slideToggle被调用的时间开始的延迟,直到它被调用的属性改变display: hidden为display: block,反之亦然.
这是我的代码:
$('.option-title').click( function() {
var name = $(this).attr('id');
$('.' + name).slideToggle('slow');
if($('.' + name).css('display') == "block") {
$(this).html("Add to Rotation? <div class=\"retract-icon\">");
} else {
$(this).html("Add to Rotation? <div class=\"expand-icon\">");
}
});
Run Code Online (Sandbox Code Playgroud)
if()条件的第一部分执行正常,因此必须将条件视为真,但再次单击时,第一个条件仍被视为真,并且内容.option-title不会更改.
我怎么能按照上面的描述使它工作?
任何帮助将不胜感激 ;).
比方说,我有以下Javascript对象:
var Object = {
Person_A: { name: 'James', age: 40, country: 'Spain' },
Person_B : { name: 'Smith', age: 50, country: 'France' }
}
Run Code Online (Sandbox Code Playgroud)
我想知道对象中有多少属性Object,并以数字方式访问这些属性,例如通过Object[n].
到目前为止(我不太使用Javascript对象,但在使用AJAX时我确实使用JSON作为返回格式)我不知道Javascript对象没有length方法,也无法以数字方式访问.
我试图将Javascript对象转换为在进行AJAX调用时返回的相同类型的JSON(JSON作为具有长度方法的对象返回,并且在数字上可访问 - 只需读取另一个线程,也许我就是'我错了 - 现在仔细检查)使用JSON.parse(JSON.stringify(Object))但只是返回相同的确切对象.
所以,我的问题是,采用像示例这样的对象的最有效方法是什么,并使其可以在数字上访问并有一个length方法.
非常感谢任何帮助(请询问您是否需要澄清我的问题).
谢谢.
这是我在PHPdoc中没有看到的东西switch()所以我不确定它是否可能,但我想要一个多条件的情况,例如:
switch($this) {
case "yes" || "maybe":
include "filename.php";
break;
...
}
Run Code Online (Sandbox Code Playgroud)
这是有效的语法/这是否可能与switch()声明?