1

Google 検索結果ページからデータを取得してそのデータを保存する方法 #,

URL からデータを取得するコードがありますが、Google 検索結果からデータを取得できません...

助けてください

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 接続>>:"+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 = 応答 int ii=0; 文字列 st=""; System.out.println(" * ** * ** * ** * ** * ウェブページの出力 * ** * ** * ** * * "); 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());

4

1 に答える 1

4

スクリーン スクレイピングよりもこの API を使用する方が簡単であるため、Google 検索からデータを取得する場合は、Google JSON Search APIを使用してください。

また、この API を使用する場合は利用規約を参照してください。許可されていない提案にこのデータを使用する可能性があります。

于 2012-10-05T06:59:56.830 に答える