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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T10:56:38+00:00 2026-05-27T10:56:38+00:00

Perhaps I should back up a bit to explain what I’m trying to do.

  • 0

Perhaps I should back up a bit to explain what I’m trying to do.

I’m trying to make an app that will notify me half hour before it is sunset. I like to work on my blueprints up in the mountains however I have a habit of losing track of time and getting stuck up there in the dark. IT would be a lot easier if I knew where I was going to be every day however due to travel I am constantly at different places between Sacramento and Dover. So I want to make an application that can programatically get the data from http://www.timeanddate.com/worldclock/sunrise.html. That website contains a dropdown list where a location is selected and then it takes you to a table that contains the sunset time for the day (and other information not relevant to me).

I ran the process through a program called Fiddler and found that it uses a get request on the value selected in the dropdown box. For example, when I select USA – California – Sacramento the web traffic (according to fiddler) is as follows:

GET http://www.timeanddate.com/worldclock/astronomy.html?n=217 200 OK
(text/html)

So, I think I can pass the n=217 in a WebRequest

 WebRequest request = WebRequest.Create("http://www.timeanddate.com/worldclock/astronomy.html?n=217");        
 request.Credentials = CredentialCache.DefaultCredentials;
 HttpWebResponse response = (HttpWebResponse)request.GetResponse();

But the problem is I need my program to select Sacramento or Dover etc in code. I Imagine something like

public string GetCityValue(string city)
{
    string cityvalue = null;

    if (city.Contains("Sacramento")) 
    {
        cityvalue = "217";
    }

    if (city.Contains("Dover"))
    {
        cityvalue = "217";
    }

    return cityvalue; 
}

Or perhaps there is a way to put all the dropdown list otions into a list and search the list for the string in the method parameter, anyway those details dont worry me for now. Mostly I just am confused on how I can select a city from the list and get the table on generated page with my own code.

Please let me know if I failed to give necessary information and such.

Thanks

  • 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-05-27T10:56:39+00:00Added an answer on May 27, 2026 at 10:56 am

    This seems like a use case for a dictionary:

    //setup dictionary
    Dictionary<string, int> cityMapping = new Dictionary<string, int>()
    {
        { "Sacramento", 217 },
        { "Dover", 218 }
    };
    
    //query dictionary:
    int cityCode = cityMapping["Sacramento"];
    

    You may want to put this mapping into an XML file so you can more easily update and change it. For example given this XML:

    <CityMappings>
      <City name="Sacramento" code="217"/>
      <City name="Dover" code="218"/>
    </CityMappings>
    

    You could create your cityMapping dictionary like this:

    var cityMapping = XElement.Load("test.xml")
                                .Descendants("City")
                                .ToDictionary(x => x.Attribute("name").Value, 
                                              x => int.Parse(x.Attribute("code").Value));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a web app that should play back an RTSP/RTP stream from a
I am trying to develop a piece of code in Java, that will be
I am building a web application that will have a fair bit of forms.
Right, perhaps I should be using the normal Python lists for this, but here
Can you create websites with Chinese characters in PHP? UPDATE: Perhaps I should have
[EDIT] Hmm. Perhaps this question should be titled what is the default user-input dialog
I am not sure, whether I should use for -loop. Perhaps, like for i
I'm new to publishing Android apps. Our app's name and the string that users
I'm trying to find a way to write some unit-tests that can be used
I'm creating icons in my app using LoadIconWithScaleDown() . I also fall back to

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.