Anirudh
Anirudh

Reputation: 19

how to retrive data from google search result page and save that data,is it possible or not..?

how to retrive data from google search result page and save that data #,

i have code to retrive the data from URL , but i cant retrive the data from google search result...

plz help me

code to retrive the data from URL

enter code here  URL iurl = new URL("https://www.google.co.in/search?q=Anirudhcreative%2Cprojects&sub=Submit+Query");
URLConnection urlconn = iurl.openConnection();

System.out.println("url connection>>:"+urlconn);

File f = new File("Ani 7 hindi gogole out put.html");  //************************************ file name ***

FileOutputStream fop = new FileOutputStream(f); BufferedReader br = new BufferedReader(new InputStreamReader(urlconn.getInputStream())); String line; //PrintWriter pw = respons int ii=0; String st=""; System.out.println("************* output of web page ***********"); while((line=br.readLine())!= null) {

System.out.println(""+line+"");
ii++;

st=">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"+ii;
System.out.println(">>>>>>>>>"+ii);
if(f.exists()){
fop.write(line.toString().getBytes());

//fop.write(st.toString().getBytes());

Upvotes: 1

Views: 1740

Answers (1)

Pigueiras
Pigueiras

Reputation: 19356

Don't do that, use the Google JSON Search API if you want to retrieve data from the google search because it's easier to use this API than screen scraping.

Also look at the Terms and Conditions when using this API, maybe you are going to use this data for not allowed proposes.

Upvotes: 4

Related Questions