So basically we if we want to get the Alexa Page Rank for
a certain url, we have to access their xml API, (I'm sure there's
JSON outhere) and pass the url via querystring, and then just parse
the response.
Here is how:
public static int getAlexa(String URL) {
int AlexaRank = 0;
WebRequest request = WebRequest.Create("http://data.alexa.com/data? cli=10&dat=snbamz&url=" + URL);
WebResponse response = request.GetResponse();
StreamReader sr = new StreamReader(response.GetResponseStream());
string line = "";
while ((line = sr.ReadLine()) != null) {
Regex rankRegex = new Regex("");
Match match = rankRegex.Match(line);
if (match.Success) {
AlexaRank = int.Parse(match.Groups[1].Value);
}
}
sr.Close();
return AlexaRank;
}
and there you go, you can also convert this int, to string
or whatever, nothing complex.
Hope you find this code snippet usefull :)
does not work
ResponderEliminartry making a regex for the following line in the response:
ResponderEliminarto get the "TEXT=..." value, and you should get the alexa rank
Yes, I saw there was no regex. Do you have it? I guess I will make it.
ResponderEliminarit spits out xml here, http://data.alexa.com/data?cli=10&dat=snbamz&url=google.com
ResponderEliminaryes, I'm sorry about the reges, I forgot that (lazy me...).
ResponderEliminaror, you can use an xml parser as well, and get the node you want, the XmlDocument class should do the trick.
Website Alexa Ranks can be very easily fetched using PowerShell. See this -
ResponderEliminarhttps://ridicurious.com/2018/09/21/how-to-check-alexa-ranking-using-powershell/