{"id":47539,"date":"2021-12-04T13:16:08","date_gmt":"2021-12-04T05:16:08","guid":{"rendered":"http:\/\/www.xyryd.com\/?p=47539"},"modified":"2021-12-04T13:16:08","modified_gmt":"2021-12-04T05:16:08","slug":"php%e6%8a%93%e5%8f%96%e7%bd%91%e7%ab%99%e5%85%b3%e9%94%ae%e8%af%8d%e5%9c%a8%e7%99%be%e5%ba%a6%e5%85%b7%e4%bd%93%e6%8e%92%e5%90%8d-%e4%bb%a3%e7%a0%81%e5%ae%9e%e4%be%8b","status":"publish","type":"post","link":"http:\/\/www.xyryd.com\/47539.html","title":{"rendered":"php\u6293\u53d6\u7f51\u7ad9\u5173\u952e\u8bcd\u5728\u767e\u5ea6\u5177\u4f53\u6392\u540d \u4ee3\u7801\u5b9e\u4f8b"},"content":{"rendered":"\n

php\u4ee3\u7801\u5339\u914d\u67d0\u4e2a\u7f51\u7ad9\u53ca\u5173\u952e\u8bcd\u5728\u767e\u5ea6\u7684\u641c\u7d22\u6392\u540d<\/p>\n\n\n\n

<?php\r\nfunction s($keyword,$url,$page = 1){\r\n    static $px = 0;\r\n    $rsState = false;\r\n   \r\n    $enKeyword = urlencode($keyword);\r\n    $firstRow = ($page - 1) * 10;\r\n   \r\n    if($page > 10){\r\n        die('10\u9875\u4e4b\u5185\u6ca1\u6709\u8be5\u7f51\u7ad9\u6392\u540d..end');\r\n    }  \r\n    $contents = file_get_contents(\"http:\/\/www.baidu.com\/s?wd=$enKeyword&&pn=$firstRow\");\r\n    preg_match_all('\/<table [^>]*?class=\"result\"[^>]*>[\\s\\S]*?< \\\/table>\/i',$contents,$rs);\r\n    foreach($rs[0] as $k=>$v){\r\n        $px++;\r\n        if(strstr($v,$url)){\r\n            $rsState = true;\r\n            preg_match_all('\/<h3 [\\s\\S]*?(<a[\\s\\S]*?<\\\/a>)\/',$v,$rs_t);\r\n            echo '\u5f53\u524d \"' . $url . '\" \u5728\u767e\u5ea6\u5173\u952e\u5b57 \"' . $keyword . '\" \u4e2d\u7684\u6392\u540d\u4e3a\uff1a' . $px;\r\n            echo '<br \/>';\r\n            echo '\u7b2c' . $page . '\u9875;\u7b2c' . ++$k . \"\u4e2a<a target='_blank' href='http:\/\/www.baidu.com\/s?wd=$enKeyword&&pn=$firstRow'>\u8fdb\u5165\u767e\u5ea6<\/a>\";\r\n            echo '<br \/>';\r\n            echo $rs_t[1][0];\r\n            break;\r\n        }\r\n    }\r\n    unset($contents);\r\n    if($rsState === false){\r\n        s($keyword, $url,++$page);\r\n    }\r\n}\r\nif(isset($_POST['submit'])){\r\n   \r\n    $time = explode(' ',microtime());\r\n    $start = $time[0] + $time[1];\r\n\r\n    $url = $_POST['url'];\r\n    if( count(explode('.',$url)) < = 2){\r\n\r\n        $url = ltrim($url,'http:\/\/');\r\n        $url = 'www.' . $url;\r\n    }\r\n\r\n    s($_POST['keyword'],$url);\r\n   \r\n    $endtime = explode(' ',microtime());\r\n\r\n    $end = $endtime[0] + $endtime[1];\r\n\r\n    echo '<hr>';\r\n    echo '\u7a0b\u5e8f\u8fd0\u884c\u65f6\u95f4: ';\r\n    echo $end - $start;\r\n    die();\r\n}\r\n\r\n?>\r\n\r\n< !DOCTYPE html PUBLIC \"-\/\/W3C\/\/DTD XHTML 1.0 Transitional\/\/EN\" \"http:\/\/www.w3.org\/TR\/xhtml1\/DTD\/xhtml1-transitional.dtd\">\r\n<html xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text\/html; charset=gbk\" \/>\r\n<title>\u6293\u53d6\u6392\u540d<\/title>\r\n\r\n<\/head>\r\n\r\n<body>\r\n<form action=\"\" method=\"post\">\r\n    <ul>\r\n        <li>\r\n            <span>\u5173\u952e\u5b57\uff1a<\/span><input type=\"text\" name=\"keyword\"\/>\r\n        <\/li>\r\n        <li>\r\n            <span>url\u5730\u5740\uff1a<\/span><input type=\"text\" name=\"url\"\/>\r\n        <\/li>\r\n        <li>\r\n            <input type=\"submit\" name=\"submit\" value=\"\u641c\u7d22\"\/>\r\n        <\/li>\r\n    <\/ul>\r\n   \r\n<\/form>\r\n<\/body>\r\n<\/html>\r\n<\/h3><\/table><\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"

php\u4ee3\u7801\u5339\u914d\u67d0\u4e2a\u7f51\u7ad9\u53ca\u5173\u952e\u8bcd\u5728\u767e\u5ea6\u7684\u641c\u7d22\u6392\u540d<\/p>\n","protected":false},"author":1,"featured_media":43088,"comment_status":"open","ping_status":"","sticky":false,"template":"single-with-sidebar","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[13,238,106],"aioseo_notices":[],"_links":{"self":[{"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/posts\/47539"}],"collection":[{"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/comments?post=47539"}],"version-history":[{"count":0,"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/posts\/47539\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/media\/43088"}],"wp:attachment":[{"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/media?parent=47539"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/categories?post=47539"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.xyryd.com\/wp-json\/wp\/v2\/tags?post=47539"}],"curies":[{"name":"wp","href":"http:\/\/api.w.org\/{rel}","templated":true}]}}