codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  how to extract search engine results  amitha_n at 11:45 on Wednesday, April 13, 2005
 



hi iam new to java
i want to extract URLs from search engine such google
i tried it and iam getting one URL
how to get all URLs
here is my code
import java.net.*;
import java.io.*;
import java.util.*;
class Googly2
{
public static void main(String[] args)
{
try{
//Reading the keyword from text file
DataInputStream din=new DataInputStream(new BufferedInputStream(new FileInputStream("/forum/CDocuments_and_SettingsAdministratorDesktopkeywordfile.txt")));
String str;
while((str=din.readLine())!=null)
{
System.out.println("\nKeyword :" +str);
//Creating URL
URL url = new URL("http://www.google.com/sponsoredlinks?hl=en&lr=&q="+str);
URLConnection conn = url.openConnection();
conn.setRequestProperty("User-Agent","");
conn.connect();
//Reading the page
BufferedReader in =
new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
String lines;
String result="";
String urlResult="";

int c=0;
while((line=in.readLine())!=null)
{
if(line.indexOf("return ss")!=-1)
{
c++;
System.out.println("C :"+c);}
if(line.indexOf("return ss")!=-1)
{
System.out.println("C :"+c);
urlResult= line.substring(line.indexOf("return ss"),line.indexOf("onMouseOut"));

}
}




System.out.println("\nURL : "+urlResult);

}


}catch(Exception e)
{
e.printStackTrace();
}

}}










CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Multiple rows from form into XML?
•  Dhtml menu, submenu losing focus. I`m so close!
•  Re: CLICK ON ROW AND CHECK The CHECKBOX
•  Packaging of applet & resources
•  Facing problems with nested menus
•  complicate JavaScript function
•  Deleting from database (ms. Access)
•  Re: How to open a MS Word document from Javascript
•  Re: HELP WITH STRINGS :(


Recent Articles
Communicating with the Database (Using ADO)
MagicGrid
Simple Thumbnail Browsing Solution
Type Anywhere
A Better Moustrap: FmtDate to replace FormatDateTime
ASP.NET Forum Source Code
Internal Search Engine
Javascript Growing Window
Simple date validation
Search engine friendly URLs using ASP.NET (C#.NET)


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2005