I'm trying to scrape google with jsoup and I'm scraping it every 10 seconds, but it's giving me the "org.jsoup.HttpStatusException: HTTP error fetching URL. Status=429" after scraping it for a while, which means I'm making too many requests, but I'm only scraping it once every 10 seconds.
Now, whenever I try to scrape it, it's returning "null", which means it's giving me the too many request error and won't let me scrape anymore. I even tried waiting 10 minutes before trying to scrape again, but it's still giving the too many request error. How would I fix this?
MainActivity.java:
public String getContent(String link) throws InterruptedException, IOException {
tuna tuna = new tuna(link);
Thread thread = new Thread(tuna);
thread.start();
thread.join();
String value = tuna.getValue();
}
String link = "www.google.com";
string content = getContent(link);
tuna.java:
public class tuna implements Runnable {
String link;
Document doc;
String content;
public tuna (String x) throws IOException {
link = x;
}
public void run() {
try {
doc = Jsoup.connect(link).get();
content = doc.html();
} catch (IOException e) {
e.printStackTrace();
}
}
public String getValue() {
String returnContent = content;
return returnContent;
}
}