Gathering HTML from Google News

Hi there,
Using the following code i'm trying to simply print the source code of http://news.google.co.uk/?ned=uk&topic=n
but i get an IOException, i was wondering if anybody knew why, and if there is a way around it.
public static String newsPage = "http://news.google.co.uk/?ned=uk&topic=n";
try {
            URL url = new URI(newsPage).toURL();
            BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
            String inputLine;
            while((inputLine = in.readLine())!=null) {
                newsHTML = inputLine;
                System.out.println(newsHTML);
        } catch (MalformedURLException e) {System.out.println("Malformed URL Exception");
        } catch (URISyntaxException e) {System.out.println("URI Syntax Exception");
        } catch (IOException e) {System.out.println("IO Exception");
        }Thanks in advance :)

Ok, that returned the following error
Server returned HTTP response code: 403 for URL:
http://news.google.co.uk/?ned=uk&topic=n
java.io.IOException: Server returned HTTP response
code: 403 for URL:
http://news.google.co.uk/?ned=uk&topic=n
at
at
at
at
sun.net.www.protocol.http.HttpURLConnection.getInputSt
ream(HttpURLConnection.java:1149)
at java.net.URL.openStream(URL.java:1007)
at grabber.Main.getHeadlines(Main.java:161)
at grabber.Main.main(Main.java:69)403 is forbidden. I suspect that google is preventing programs such as yours from doing what it is are trying to do.
To circumvent this you will likely have to do something weasely with the HTTP headers. Like fool google into thinking you are IE or Firefox or something.
But I am not going to give more advice than that because the fact it is 403 in the first place strongly suggests that you shouldn't be doing what you are trying to do for legal reasons.

Similar Messages

  • When I select HTML from Create New, it appears in Doc tab as untitled-1.XHTML

    Every time I select HTML from Create New in the Welcome screen, it appears in the Document tab as untitled-1.XHTML, with a green icon.  In the past it's always come up as document-1.html, with no icon, as in my textbook.  I don't know why it's doing this, whether it's important (I would guess that it is), or how to change it.  I'm new to Dreamweaver.  Any help would be much appreciated...

    Which version and build # of DW do you have?  You'll find it under Help > About Dreamweaver.
    Also, which preferences have you specified for new documents?
    Go to Edit > Preferences > New Document. 
    The default extension should be either  .htm or .html, .shtml or .php -- depending on the type of files you work with most. 
    Nancy O.

  • Why I cannot play video clips from Google news page? It is only a white box without video when video icon is tauched!

    Why I cannot play video clips from Google News page?

    It looks,like the videos on the web page are flash, which will not play on the pad.  That is why the made an app. Go to the store and get the free google news app.  It is laid out a little different, but any videos in it will play.

  • Parsing HTML from Google API results

    Hello,
    I just downloaded the Google API (http://www.google.com/apis) and I am trying to parse the HTML content which is returned so that it can be displayed in a TextArea or some other GUI component.
    Here are my questions:
    1. Is there a Java class that can parse HTML and display it correctly?
    2. If not, are there are third party, prefabably free Java components that can do that?
    3. Has anyone tried out the Google API? Any interesting applications?
    Thank you.
    Hanxue

    To convert plain text to html, you can parse the text with a simple code like this
    1.
    String inputText = getInputText(); //
    StringBuffer HTMLOutputText = new StringBuffer();
    java.util.StringTokenizer st = new java.util.StringTokenzier(inputText, "\n\r");
    while ( st.hasMoreTokens() ) {
    HTMLOutputText.append(st.nextToken());
    HTMLOutputText.append("<br>");
    /// insert the top level HTML tags
    HTMLOutputText.insert(0, "<HTML> <HEAD><TITLE> Some Title</TITLE></HEAD> <BODY>");
    HTMLOutputText.insert( HTMLOutputText.getLength(), "</BODY> </HTML>" );
    2. even simpler, but as far as I know it doesn't display right in a JEditorPane
    String inputText = getInputText();
    inputText = "<HTML> <HEAD><TITLE> Some Title</TITLE></HEAD> <BODY> <PRE> <TT>" +
    + inputText + "</TT></PRE></BODY> </HTML>";

  • Problems Exporting HTML from Fireworks (new to Fireworks)

    Forgive me if this is a rudimentary question, but I've searched the help files as well as online and I'm not finding anything on it.  I have a bunch of PNG image maps I need to update (someone else created the PNGs in Fireworks several years ago).  I open them, make the updates and choose export HTML and Images, and then it allows me to choose some options for the HTML, but not for the images.  For one thing, it keeps putting the image file somewhere other than where I want it (and as a result I have to move the image file and update the HTML manually), and it doesn't let me choose what kind of image I want to export.  I want JPEGs, but it keeps cranking out GIFs.  What am I missing here?
    Thanks!

    Ok, I finally noticed the Put Images in Subfolder check box, which allows me to choose where I want the image to end up (not exactly intuitive, though, as I don't want the image in a subfolder, per se, I want it in the same folder as the HTML!).  And I still don't see where I can choose what type of image to export.  (What's with this "Export" crap anyway?  Why not Save for Web and Devices like every other Adobe product I use?  I know, I know, it's related to Fireworks' Macromedia origins...still, let's get on the same page, here!)

  • After updating to 4.0.1 (linux, x86-32) the popup-blocker prevents to open links from web-pages, e.g. from google news! Why?

    I just updated to 4.0.1 and since that moment the popup-blocker seems to block even normal links which are opened in a tab in previous versions.
    When I disable the popup-blocker everything works as before (but popups will open of course).

    I just updated to 4.0.1 and since that moment the popup-blocker seems to block even normal links which are opened in a tab in previous versions.
    When I disable the popup-blocker everything works as before (but popups will open of course).

  • Google News Configuration

    Hi,
    On HOME work center, we have dashboard for latest news which provide the top stories from google news.
    I need to know, how we can control the news like category, source, display, etc.
    Kindly let me know if there any configuration available to personalize it.
    Thanks in advance
    Govind Sharma

    Hi Govind,
    if you are using HTML client then this link will be helpful http://www.youtube.com/watch?v=JFj4aUkWAtI
    In Silverlight client you can personalise the screen, you can add other RSS feed from different sources.
    give a try and let me know if it helps.
    Regard
    Sunil

  • When I use the shortcut to open a new window in safari (command N), I get a 404 error message from Google. How do I change where 'Command N' routes to?

    When I use the shortcut to open a new window in safari (command N) on my Macbook Pro, I get a 404 error message from Google. How do I change where 'Command N' routes to? 

    It's not necessary to change the Command N keystroke..
    From your Safari menu bar click Safari > Preferences then select the Privacy tab.
    Click:   Remove All Website Data
    Then delete the cache.
    Open a Finder window. From the Finder menu bar click Go > Go to Folder
    Type or copy paste the following
    ~/Library/Caches/com.apple.Safari/Cache.db
    Click Go then move the Cache.db file to the Trash.
    Quit and relaunch Safari to test.
    If that didn't help, troubleshoot Safari extensions.
    From the Safari menu bar click Safari > Preferences then select the Extensions tab. Turn that OFF, quit and relaunch Safari to test.
    If that helped, turn one extension on then quit and relaunch Safari to test until you find the incompatible extension then click uninstall.

  • Now that all of our school district iPads have been upgraded to ios 7 ...I am unable to save a photo from google in my photo gallery. Whats the new technique for this???

    now that our iPad is upgraded to ios 7.+, I cannot save images from google to photo gallery the old conventional way. Whats the new technique?

    actually with new ios 7
    select image from search,
    once image has been selected and enlarged you may tap/hold select
    then options will appear...then 'save image'

  • When accessing favorites imported from IE8, duplicate links appear for those bookmarks on Google new tab page, while things I have bookmarked in Firefox appear normally, as a single link.

    For several months now, I have had this issue. I'm not sure if this is an issue with Google Toolbar or Firefox, but I have uninstalled and re-installed the toolbar several times, and the same thing keeps happening when I access anything Imported from IE8. Anything I originally bookmark in Firefox appears as a single link on the Google new tab page, while my favorites from IE8 appears twice. Everything appears as normal in the Firefox Bookmarks menu. This doesn't seem to affect functionality in any way, but it is rather irritating at times. Is it possible it could be a bug in IE8? I'm curious to see if anyone knows of a solution to this issue. Any help or input is greatly appreciated. Has anyone else had this happen? I have the latest versions of Google Toolbar and Firefox, so far as I'm aware. Thanks, once again, for your time and input.

    Thanks to jscher! With some help from AVG my AVG & Google browser panels now work OK. But I've taken the advice & disabled several extensions including the Disconnect. The browsers are still OK after re-launching them so I keep fingers crossed.
    My original problem was that I had suddenly found a small popup window appearing, over the browser window, that I couldn't get rid of. It contained an advisory to the effect that Windows couldn't find the file popuptransparent[dot]xul. I tried searching for that to see what it was and in the course of doing that I seem to have executed it. Then was when the trouble started.
    I have 3 instances of that file in my computer and would dearly like to get rid of them if they are of no use to me. Any advice there?

  • HT4872 I have not been able to import contacts from google or my android to my new I-phone 5. This article helps to a point until error message "cannot create account" already exist is received. Please help.

    I have not been able to import contacts from google or my android to my new I-phone 5. This article helps to a point until error message "cannot create account ... already exist" is received. Please help.

    -Reece,
    We only have 1 single domain, 1 domain forest, no subdomains, only alias. I had replied to the other post as well. But I am happy to paste it here in case anyone want to read it.
    So, after a few months of testing, capture and sending logs back and forth to Apple Engineers, we found out there is a setting in AD, under User Account that prevent us to log into AD from Mountain Lion. If you would go to your AD server, open up a user account properties, then go to Account tab, the "Do not require Kerberos preauthentication" option is checked. As soon as I uncheck that option, immediately I was able to log into AD on the Mac client. Apple engineers copied all my AD settings and setup a test environment on their end and match exact mine AD environment. They was able to reproduce this issue.
    The bad part about this is... our environment required the "Do not require Kerberos preauthentication" is checked in AD, in order for our users to login into some of our Unix and Linux services. Which mean that it is impossible for us to remove that check mark because most, if not all of them some way or another require to login into applications that run on Unix and Linux. Apple is working to see if they can come up with a fix. Apparently, no one has report this issue except us. I believe most of you out there don't have that check mark checked in your environment... Anyone out there have any suggestion to by pass or have a work around for this?

  • Ff6.0.2: New Instance of Awesome Bar's default search changing from Google.

    The default search engine for my Awesome Bar changed from Google to Yahoo after today's update to 6.0.2.
    This issue is similar to http://bit.ly/pRq0SM - but like I said, I'm on v6.
    I'm unable to change this back to Google (or ''from'' anything other than Yahoo), even after disabling all add-ons, checking settings in about:config, and completely removing Yahoo from my search-engine options.
    For anyone interested in replying, '''''please note''''' that I'm talking about the ''Awesome Bar'' - ''not'' the Search Bar. The Awesome Bar isn't so awesome if I still have to rely on the Search Bar.
    Thanks! :-)

    Oh, thanks! You've made my day.
    IMHO the better solution would be to add some configuration option for the address bar search engine in browser configuration wizard. This new "feature" makes search bar useless, as for me.

  • Embedded HTML form disappears from "Featured News Widget"

    Hello!
    I am using the featured news widget for my tabs. I have a few forms that need to included. I've embedded the html from jotform (where I created the forms). I added it the widget. It works fine on the first rollover, but when you go off and then go back to it, the form disappears. Not sure how to fix this.
    This an example of what I'm referring to: http://verticalevent.org/verticalchallenge.html
    If you click on "vertical involvement", the form shows up. Then if you click on another tab and go back to "vertical involvement", the form disappears.
    Thanks for the help!!

    Nevermind. Fixed the issue. It was a jotform. Use the iframe code instead of embed.

  • I keep getting google news in my email and I don't want to. how do I stop google from coming to my email?

    I keep getting google news in my email. How do I stop getting it in my mail?

    It's likely that you subscribed to it at some point - most email of that flavor has a link for unsubscribing. Found this on a quick Google search - http://support.google.com/reader/bin/answer.py?hl=en&answer=73062.
    Clinton

  • A new App from Google they Calling it Opinion Rewards

    This might be something neat Just seen this Via D.L. its a Rewards app from Google might be worth reading and learning more about.. here's the very lengthy link from.. b33
    Droid Life  http://www.droid-life.com/2013/11/06/google-releases-google-opinion-rewards-app-to-android-answer-surveys-and-receive-play-store-credit/

    Are you sure your AppleID is NOT tied to the US store? If you are trying to buy an app from the Swedish store you will be unable to do that. Some apps are only available on certain stores. That is why you get the "Cannot connect to the iTunes store" message when trying to buy that app. Your updates are being done from the US store ; thats why you can update sometimes and sometimes not.
    If you keep encountering problems contact iTunes support. They will help you sort it out.

Maybe you are looking for