Obtain the webpage source code keyword and description in regular expressions. The problem is:
Scenario 2:
Note: it may be case sensitive, and there is name, which is different from the content attribute [color = # FF6600]. [/color]
The younger brother tried to write it. he could only match one webpage and did not know what the problem was. Thank you!
Keyword:
1.preg_match("/
tmpHtml,$inarr); 2.preg_match("/
tmpHtml,$inarr2);
1.preg_match("/
tmpHtml,$inarr);2.preg_match("/
tmpHtml,$inarr2);
Note: Some webpages can match and some cannot.
Reply to discussion (solution)
By the way, I forgot to explain that some Web pages are like this:
Keywords and description do not have double quotation marks. No match. I hope you can help me improve it. it is best to pass the test.
Isn't there a get_meta_tags function?
Isn't there a get_meta_tags function?
+ 1, you can return an array of meta, and then extract the required
Haha, that's funny. thank you! foolbirdflyfirst yangball
Name is above:
The name is later:
Name is above:
The name is later:
Based on the upstairs, we can further conclude that:
Name in front:
<(\s*)(meta|META|Meta)(\s*)(name|NAME|Name)=(\'|\"|)(keywords|KEYWORDS|Keywords)(\'|\"|)(\s*)(content|CONTENT|Content)=(\'|\"|)(.*)(\'|\"|)(\s*)><(\s*)(meta|META|Meta)(\s*)(name|NAME|Name)=(\'|\"|)(keywords|KEYWORDS|Keywords)(\'|\"|)(\s*)(content|CONTENT|Content)=(\'|\"|)|(\'|\"|)(\s*)><(\s*)(meta|META|Meta)(\s*)(name|NAME|Name)=(\'|\"|)(description|DESCRIPTION|Description)(\'|\"|)(\s*)(content|CONTENT|Content)=(\'|\"|)(.*)(\'|\"|)(\s*)><(\s*)(meta|META|Meta)(\s*)(name|NAME|Name)=(\'|\"|)(description|DESCRIPTION|Description)(\'|\"|)(\s*)(content|CONTENT|Content)=(\'|\"|)|(\'|\"|)(\s*)>
After name:
<(\s*)(meta|META|Meta)(\s*)(content|CONTENT|Content)=(\'|\"|)(.*)(\'|\"|)(\s*)(name|NAME|Name)=(\'|\"|)(keywords|KEYWORDS|Keywords)(\'|\"|)(\s*)><(\s*)(meta|META|Meta)(\s*)(content|CONTENT|Content)=(\'|\"|)|(\'|\"|)(\s*)(name|NAME|Name)=(\'|\"|)(keywords|KEYWORDS|Keywords)(\'|\"|)(\s*)><(\s*)(meta|META|Meta)(\s*)(content|CONTENT|Content)=(\'|\"|)(.*)(\'|\"|)(\s*)(name|NAME|Name)=(\'|\"|)(description|DESCRIPTION|Description)(\'|\"|)(\s*)><(\s*)(meta|META|Meta)(\s*)(content|CONTENT|Content)=(\'|\"|)|(\'|\"|)(\s*)(name|NAME|Name)=(\'|\"|)(description|DESCRIPTION|Description)(\'|\"|)(\s*)>
The above is the regular expression to get the webpage source code keyword and description. it is a bit painful. For more information, please follow the PHP Chinese network (www.php1.cn )!