1
0
mirror of https://github.com/akaessens/NoFbEventScraper synced 2025-06-05 23:29:13 +02:00

use correct user agent and add legal info

This commit is contained in:
akaessens
2020-08-29 12:28:28 +02:00
parent 15ef35ba6c
commit 0950da98e1
2 changed files with 12 additions and 2 deletions

View File

@ -192,8 +192,13 @@ public class FbScraper extends AsyncTask<Void, Void, Void> {
try {
String url = fixURI(input_url);
// useragent needed with Jsoup > 1.12
Document document = Jsoup.connect(url).userAgent("Mozilla").get();
// use correct system user agent because of facebook ToS
String user_agent = System.getProperty("http.agent");
Document document = Jsoup.connect(url).userAgent(user_agent).get();
if (document == null) {
throw new IOException();
}
String json = document
.select("script[type = application/ld+json]")
.first().data();
@ -219,6 +224,9 @@ public class FbScraper extends AsyncTask<Void, Void, Void> {
} catch (IOException e) {
e.printStackTrace();
this.error = "Error: Unable to connect.";
} catch (Exception e) {
e.printStackTrace();
this.error = "Error: Unknown Error.";
}
return null;