2012-10-05 23 views
0

如何從谷歌搜索結果頁面retrive數據並保存數據#,

我有代碼以檢索從URL中的數據,但我不能retrive數據從谷歌的搜索結果 ...如何從Google搜索結果頁中檢索數據並保存該數據,是否有可能?

plz幫助我

代碼從URL retrive數據

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())); 絃線; // PrintWriter pw = respons int ii = 0; String st =「」; 的System.out.println(」 * ** * ** * ** * ** *網頁輸出* ** * ** * ** * *「); 而((線= 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())。

+4

歡迎來到SO。 'www.nic.in/hindi/projects'不是谷歌,那麼你是什麼意思?請妥善格式化您的代碼。 – home

回答

2

不要這樣做,如果您想從Google搜索中檢索數據,請使用Google JSON Search API,因爲使用此API比屏幕抓取更容易。

當使用這個API時,也請看Terms and Conditions,也許你會使用這個數據爲不允許的提議。

+0

嗨thanx爲您的迴應,這是我的代碼,我嘗試獲得結果 {} – Anirudh

+0

{ System.out.println(「」+ line +「」); ii ++; st =「>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>」+ ii; System.out.println(「>>>>>>>>>」+ ii);如果(f.exists()){f0}(line.toString()。getBytes()); //fop.write (st.toString()。getBytes());} – Anirudh

+0

我更新了我的Qution代碼,你可以現在檢查它............ – Anirudh

相關問題