Home > Net >  Regular expressions for c # web keywords keywords how to write?
Regular expressions for c # web keywords keywords how to write?

Time:09-25

http://seo.comcuz.com/seo/
Developed a comprehensive SEO query tools, retrieve keywords wrote,

Public static string Getkeywords (string Url)
{
WebClient wc=new WebClient ();
Wc. Encoding=Encoding. UTF8;
A string of HTML=wc. DownloadString (Url);
String reg="(? <meta name==\ "keywords " content=\ "). *? (?=\ ");
String keywords=Regex. Match (HTML, reg). The Value;
Return keywords;
}


Code above meet the following key words cannot be obtained, could you tell me how to modify the use of meta keywords for the name value of the content of the content?


<meta id="key" name="keywords" content="website building, website production, the enterprise website building, website building, website production company, corporate website production, into a connected"/& gt; <meta id="des" name="description" content="website construction is the company's good marketing method, use SEO network marketing enterprises, the website construction company through the website optimization and website production, trying to do make you satisfied 100% of websites, high-end enterprise website construction company."/& gt;




CodePudding user response:

String reg="(? <=meta (id=\ "key ")? name=\ "keywords " content=\ "). *? (?=\ ");

Note that there is space in front of the id

CodePudding user response:

This is best not to use regular, should use the dom parsing
These attributes who appeared who doesn't appear, who first who last the permutation and combination is too much

CodePudding user response:

reference 1/f, autumn red fruit reply:
string reg="(? <=meta (id=\ "key ")? name=\ "keywords " content=\ "). *? (?=\ ");

Note id before the space



I mean how other such circumstances, it is not still won't do it, how to directly obtained according to the name

CodePudding user response:

reference 4 floor comcuz response:
Quote: reference 1/f, autumn red fruit reply:

String reg="(? <=meta (id=\ "key ")? name=\ "keywords " content=\ "). *? (?=\ ");

Note id before the space



I mean how other such circumstances, it is not still won't do it, how to directly obtained according to the name
not only use the name, content may also have other name, have to have to distinguish between
You said the other, please give the sample, this is a regular expression
  •  Tags:  
  • C#
  • Related