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

@ -4,6 +4,8 @@
<h3>Open Source</h3> <h3>Open Source</h3>
<p>The source code for this application is available at <a href=" https://github.com/akaessens/NoFbEventScraper">GitHub</a>.<strong><br /></strong></p> <p>The source code for this application is available at <a href=" https://github.com/akaessens/NoFbEventScraper">GitHub</a>.<strong><br /></strong></p>
<p>If you encounter an issue, please report it to me anonymously at the <a href="https://gitreports.com/issue/akaessens/NoFbEventScraper">Bugtracker</a> or directly at <a href="https://github.com/akaessens/NoFbEventScraper/issues">GitHub</a>.</p> <p>If you encounter an issue, please report it to me anonymously at the <a href="https://gitreports.com/issue/akaessens/NoFbEventScraper">Bugtracker</a> or directly at <a href="https://github.com/akaessens/NoFbEventScraper/issues">GitHub</a>.</p>
<h3>Legal</h3>
<p>This application is intended for saving single, publicly available events into a personal calendar. Do not use it to automatically collect data and comply with facebook's <a href="http://www.facebook.com/apps/site_scraping_tos_terms.php">Automated Data Collection Terms</a>.</p>
<h3>Donations</h3> <h3>Donations</h3>
<p>I develop this application in my free time. If you like it, you can donate at <a href="https://www.paypal.me/andreaskaessens">PayPal</a>.</p> <p>I develop this application in my free time. If you like it, you can donate at <a href="https://www.paypal.me/andreaskaessens">PayPal</a>.</p>
<p><a title="PayPal" href="https://www.paypal.me/andreaskaessens"><img src="https://www.paypalobjects.com/webstatic/de_DE/i/de-pp-logo-100px.png" /></a></p> <p><a title="PayPal" href="https://www.paypal.me/andreaskaessens"><img src="https://www.paypalobjects.com/webstatic/de_DE/i/de-pp-logo-100px.png" /></a></p>

View File

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