| Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате |
| Форум программистов > Java: Работа с сетью > GetURLs |
| Автор: Zhenia87 22.3.2008, 19:28 | ||||
| Мне надо записать все урл которые выдает гугл при запросе(насколько я понял с описания задания и примера). У меня есть программа которая делает парсинг сайта, но когда я беру урл, например, такой как в примере задания: http://www.google.com/search?hl=en&q=%22google.com%22+-inurl%3Agoogle.com&btnG=Search , то программа выдает такое: Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: http://www.google.com/search?hl=en&q=%22google.com%22+-inurl%3Agoogle.com&btnG=Search at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1170) at java.net.URL.openStream(URL.java:1007) at geturls.ReadTag.<init>(ReadTag.java:44) at geturls.ReadTag.<init>(ReadTag.java:37) at geturls.GetURLs.<init>(GetURLs.java:14) at geturls.GetURLs.main(GetURLs.java:41) Если , я беру например такой урл : www.google.com , то программа отлично работает. ЗАДАНИЕ: Name of project: GetUrls description: Goal of the program is to make a lists of links copied from the google pages for each keyword supplied, Using also words collected in order to present less pages on google. 1.The program takes a list of "Keywords" (notice keywords can be queries to google that includes google commands, for example: "google.com -inurl:google.com" is considered a keyword aswell. This list is called: main_keywords.txt 2.For each of the keywords, The program will search google (using a different datacenter and different proxy each time), And will need to make 2 lists: 1. Recursive_words.txt - The program will append all the words collected from all the google pages (1.....maximum), each word will be on a new line (Notice words can be unicode also). (Remove duplicate words, remove html elements like <a href=> etc...) 2. Collected_Links.txt - The program will append all the full urls collected from the google pages to this list. example: ---------------------------- Main_Keywords.txt contains: ______________________________ "google.com" -inurl:google.com "yahoo.com" -inurl:yahoo.com ______________________________ program will query google like this (notice that "" is part of the query): http://www.google.com/search?hl=en&q=%22google.com%22+-inurl%3Agoogle.com&btnG=Search http://www.google.com/search?hl=en&q=%22yahoo.com%22+-inurl%3Ayahoo.com&btnG=Search then: 1.The program will take all the "site descriptions" (written in color black) and append them to Recursive_words.txt. each word in a new line. 2.The program will take all the "full urls" (written in color green) and will append the links, each in different lines, to Collected_Links.txt. ПРОГРАММА ДЛЯ ПАРСИНГУ САЙТА: ReadTag.java
GetURLs.java
|