Php RegExp未提供cURL的预期结果
下面是我的代码,它没有提供预期的结果 首先,它应该使用Php RegExp未提供cURL的预期结果,php,regex,curl,libcurl,Php,Regex,Curl,Libcurl,下面是我的代码,它没有提供预期的结果 首先,它应该使用cURL提供页面的完整html内容,然后使用regexp,当我直接向他们提供htmlcontent时,它会提供预期的结果,但使用cURL不会提供相同的结果 假设我将下面的内容传递给htmlcontent变量,然后RegExp提供正确的结果 $htmlContent = '<table id="ctl00_pageContent_ctl00_productList" class="product-list" cellspacing="0"
cURL
提供页面的完整html内容,然后使用regexp,当我直接向他们提供htmlcontent
时,它会提供预期的结果,但使用cURL不会提供相同的结果
假设我将下面的内容传递给htmlcontent
变量,然后RegExp
提供正确的结果
$htmlContent = '<table id="ctl00_pageContent_ctl00_productList" class="product-list" cellspacing="0" border="0" style="width:100%;border-collapse:collapse;">
<tr>
<td class="product-list-item-container" style="width:100%;">
<div class="product-list-item" onkeypress="javascript:return WebForm_FireDefaultButton(event, 'ctl00_pageContent_ctl00_productList_ctl00_imbAdd')">
<a href="/W10542314D/WDoorGasketandLatchSt.aspx">
<img class="product-list-img" src="/images/products/display/applianceparts.jpg" title="W10542314 D/W Door Gasket & Latch St " alt="W10542314 D/W Door Gasket & Latch St " border="0" />
</a>
<div class="product-list-options">
<h5><a href="/W10542314D/WDoorGasketandLatchSt.aspx">W10542314 D/W Door Gasket & Latch St</a></h5>
<div class="product-list-cost"><span class="product-list-cost-label">Online Price:</span> <span class="product-list-cost-value">$33.42</span></div>
</div>
';
这里,Regexp以相反的顺序从cURL读取我的html内容,并返回锚标记中的第一个href值。
数组值中的预期输出-/W10130694LatchAsySyWhiteHandle.aspx
任何帮助都将不胜感激
谢谢你试试这个
class="product-list-item".*?<a href="(.*?)".*?class="product-list-options"
说明:
class=“产品列表项”
匹配class=“产品列表项”
*?
尽可能少地匹配任何字符你能解释一下你的答案吗。你为什么要起诉双方的学生
http://www.universalapplianceparts.com/termsofservice.aspx
class="product-list-item".*?<a href="(.*?)".*?class="product-list-options"
MATCH 1
1. [23040-23075] `/W10130694LatchAssyWhiteHandle.aspx`