-1
からすべてのリンクを取得する方法* vedeo.com /ダウンロード?URL = https://www.youtube.com/watch?v=GQx7W3jrZiE私は<a href="https://s">https://s</a>からすべてのリンクを取得したいウェブ
しかし、私は自分のコードを実行したとき、私はちょうど最初の1を取得します。 すべてのリンクを取得するには?ループや何かを使用して、どのようにループを作成する.. 誰も私を助けることができますか?
package com.example.root.mytestjsoup;
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
public class MainActivity extends AppCompatActivity {
Button but;
TextView text;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
but = (Button)findViewById(R.id.button);
text = (TextView)findViewById(R.id.textView);
but.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new scrap().execute();
}
});
}
public class scrap extends AsyncTask<Void,Void,Void>{
String word;
Elements link;
Element linx;
String linkHref;
@Override
protected Void doInBackground(Void... params) {
try {
Document doc = Jsoup.connect("https://savedeo.com/download?url=https://www.youtube.com/watch?v=GQx7W3jrZiE").get();
link = doc.select("a[data-event]");
Elements div = doc.getElementsByAttribute("data-event");
String attr = div.attr("href"); // when it change to data-event, it will got the value of data-event.
word = attr;
}catch (Exception e){
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
text.setText(word);
}
}
}