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 8230417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:07:42+00:00 2026-06-07T17:07:42+00:00

I’m developing an app that scrapes a website for Google+1’s, Facebook shares and Tweets.

  • 0

I’m developing an app that scrapes a website for Google+1’s, Facebook shares and Tweets. I have a request method that accepts a URL and then goes off and fetches the count for each social media type.

It’s logic is as follows: –

  • Take URL
  • Do requests through local/default IP until we get rate limited/non-500 response
  • On error
    • Call SelectNewProxy() which iterates over a list of proxies and returns one at random to try (a nice way of avoiding request limits for your IP)
    • Remove bad proxy from list to avoid selecting it again
    • Start a timer which increments every second
  • When the timer == 600 (10 minutes)
    • Create new WebProxy and try to the requests behind our local/default IP again
    • Reset timer

Rinse and repeat

The code is as follows:

public string Request(string action)
{
      HttpWebRequest req;

      OnStatusChange(new MyArgs() { Message = "Status: Requesting..." });
      string response = string.Empty;

      while (response.Equals(string.Empty) && proxy != null)
      {
             try
             {
                  req = (HttpWebRequest)WebRequest.Create(action);
                  req.Proxy = proxy;
                  HandleUIMessages(action, proxy);
                  response = new StreamReader(req.GetResponse().GetResponseStream()).ReadToEnd();
              }
              catch
              {
                  //OnProxyChange(new MyArgs() { ProxyMessage = string.Format("Proxy: {0}", proxy.Address.ToString()) });
                  RemoveProxy(proxy);

                  if (!timer.Enabled)
                  {
                      timer.Interval = (int)TimeInterval.OneSecond;
                      timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
                      timer.Enabled = true;
                      timer.Start();
                  }
                  WebProxy reset = new SelectNewProxy();     
                  proxy = counter >= 600 ? reset : proxy = SelectNewProxy();
               }
      }
      return response;
}

It’s worth mentioning that I’m using ThreadPool and each request is running in it’s own thread. It seems like it would work but I don’t get the desired effect, the counter reaches ‘600’ and sets proxy = reset but it appears to only do it very briefly, possibly only for the first thread that hits it? Then timer_Elapsed is called and counter is reset. Could it be that a thread is hitting it, assigning proxy = reset and then because counter has now been reset (no longer >= 600), all subsequent queued up threads call SelectNewProxy()? Feel like I’m rambling but hopefully someone can make sense of what I’m trying to say and if I’m right in my guess, how can I ensure that all threads get proxy = reset and retry our inital IP?

Any help is much appreciated!

Thankyou

  • 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-07T17:07:44+00:00Added an answer on June 7, 2026 at 5:07 pm

    How have you declared proxy? If you are reading/writing its value on multiple threads, you should make sure you declare it with the volatile keyword, otherwise writes to proxy on one thread may not be observed by others.

    e.g.:

    volatile WebProxy proxy;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I used javascript for loading a picture on my website depending on which small

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.