To obtain the ranking digits of the keyword Baidu, use a regular expression, such as searching for csdn from Baidu. The result is as follows: HTMLcode & lt; tablecellpadding & quot; 0 & quot; cellspacing & quot; 0 & quot; class & quot; result & quot; id & quot; 1 & quot; & gt; & lt; tr & gt; & lt; the method to obtain the number of digits in the Baidu ranking keyword is mainly a regular expression.
For example, search for csdn from Baidu,
The result is as follows:
HTML code
Http://picache.baidu.com/media? Wd = require & src = local: // spider/favicon/site_www.csdn.net.png & def = local: // neverfill) "onmousedown =" return c ({'ffm ': 'as ', 'F': '779317ea ', 'F1': '9d33f1e4', 'F2': '4ca63e6b ', 'F3': '54e5243f', 'T': '123 ', 'Title': this. innerHTML, 'URL': this. href, 'p1': 1, 'y': 'fefa7e '}) "href =" http://www.csdn.net/"target =" _ blank "> Where
When the 1 in id = "1" is based on the csdn keyword, Baidu naturally ranks www.csdn.net. In "'})" href = "http://www.csdn.net/" target = "_ blank"> "this string contains the first 15th characters and is also his ranking number 1Now I can only get the entire search result from file_get_contents. how can I "extract" 1 of this id = "1? Thank you for your advice!My idea is, from "'})" href = "http://www.csdn.net this code goes forward to search for 15th notes, get him, can also.Thank you for your advice!------ Solution --------------------After, no one answered the question. it looks like they are all in a coma.$ Str ='
}';$ Pat = '/id = "([0-9]) + "/';Preg_match ($ Pat, $ Str, $ Marray );Echo $ Marray [1];
|