Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8016809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:39:19+00:00 2026-06-04T20:39:19+00:00

I want a method to get a webpage url and return count of it’s

  • 0

I want a method to get a webpage url and return count of it’s +1. I searched google and just find this and the method is:

int GetPlusOnes(string url) 
{

     string googleApiUrl = "https://clients6.google.com/rpc"; //?key=AIzaSyCKSbrvQasunBoV16zDH9R33D88CeLr9gQ";

     string postData = @"[{""method"":""pos.plusones.get"",""id"":""p"",""params"":{""nolog"":true,""id"":""" + url + @""",""source"":""widget"",""userId"":""@viewer"",""groupId"":""@self""},""jsonrpc"":""2.0"",""key"":""p"",""apiVersion"":""v1""}]";

     System.Net.HttpWebRequest request = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(googleApiUrl);
     request.Method = "POST";
     request.ContentType = "application/json-rpc";
     request.ContentLength = postData.Length;

     System.IO.Stream writeStream = request.GetRequestStream();
     UTF8Encoding encoding = new UTF8Encoding();
     byte[] bytes = encoding.GetBytes(postData);
     writeStream.Write(bytes, 0, bytes.Length);
     writeStream.Close();

     System.Net.HttpWebResponse response = (System.Net.HttpWebResponse)request.GetResponse();
     System.IO.Stream responseStream = response.GetResponseStream();
     System.IO.StreamReader readStream = new System.IO.StreamReader(responseStream, Encoding.UTF8);
     string jsonString = readStream.ReadToEnd();

     readStream.Close();
     responseStream.Close();
     response.Close();

    var json = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize(jsonString);
    int count = Int32.Parse(json[0]["result"]["metadata"]["globalCounts"]["count"].ToString().Replace(".0", ""));

    return count;
}

but there is an error in

var json = new System.Web.Script.Serialization.JavaScriptSerializer().Deserialize(jsonString);

because the Deserialize method gets two arguments and I don’t know the second argument.
does anybody know what is the second argument or know another methods that works fine?

update
I also tried

    public static Regex REGEX_GETURLCOUNT =
    new Regex(@"<div[^>]+id=""aggregateCount""[^>]+>(\d*)</div>");

    public int GetPlusOnes(string url)
    {
        string fetchUrl =
            "https://plusone.google.com/u/0/_/+1/fastbutton?url=" +
            HttpUtility.UrlEncode(url) + "&count=true";
        WebClient wc=new WebClient();
        string response = wc.DownloadString(fetchUrl);

        Match match = REGEX_GETURLCOUNT.Match(response);
        if (match.Success)
        {
            return int.Parse(match.Groups[1].Value);
        }
        return 0;
    }

but match.Success is always false!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T20:39:21+00:00Added an answer on June 4, 2026 at 8:39 pm

    Had to do something like this recently, i used:

     public partial class _Default : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                int test = GetPlusOnes("http://www.allfancydress.com/"); //Returns 11 plus ones
                Response.Write("Plus ones: " + test.ToString());
            }
    
            public static Regex REGEX_GETURLCOUNT =
             new Regex(@"<div[^>]+id=""aggregateCount""[^>]+>(\d*)</div>");
    
            public static int GetPlusOnes(string url)
            {
                string fetchUrl =
                    "https://plusone.google.com/u/0/_/+1/fastbutton?url=" +
                    HttpUtility.UrlEncode(url) + "&count=true";
                HttpWebRequest request =
                    (HttpWebRequest)WebRequest.Create(fetchUrl);
                string response = new StreamReader(request.GetResponse()
                    .GetResponseStream()).ReadToEnd();
                Match match = REGEX_GETURLCOUNT.Match(response);
                if (match.Success)
                {
                    return int.Parse(match.Groups[1].Value);
                }
                return 0;
            }
    
        }
    

    Hope this helps

    *edited out my custom proxy class, you can just cut and paste this and it will work for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

when i want compile my app with the Distribution or Release method i get
I try to write get method for my class bassed on ListView, I want
I want to get an object by a static factory method, such as Person
I want a method to return an XML Serialized Typed object. Is there an
For a GET request I've tried this simple method: NSString *urlAddress = @"http://example.com/"; NSURL
I want to get webpage headers using selenium and I am thinking to use
I want to get html content from a webpage in my windows app. Im
I want to implement a java method which takes URL as input and stores
i use java reflections to get methods used in a class.I also want to
i used java reflections to get methods from a class(loaded those classes).Now i want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.