mirror of
https://github.com/akaessens/NoFbEventScraper
synced 2025-06-05 23:29:13 +02:00
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
85f420e15d | |||
c119a163c0 | |||
08c1040679 | |||
2efaafa38b | |||
262c1c4377 | |||
26021d540c |
@ -1,4 +1,8 @@
|
||||
# Changelog
|
||||
## v0.4.1 (11)
|
||||
- Fix events not displaying correctly after activity resume
|
||||
- add share action on each event
|
||||
- add URL shortener redirection for fb.me
|
||||
## v0.4.0 (10)
|
||||
- Support pages with upcoming events *beta*
|
||||
- Display events in a scrollable card-based view
|
||||
|
@ -20,6 +20,10 @@ This source contains the information which is used to create a calendar entry.
|
||||
<img src="https://fdroid.gitlab.io/artwork/badge/get-it-on.png" height="75">
|
||||
</a>
|
||||
|
||||
# Changelog
|
||||
|
||||
[CHANGELOG](CHANGELOG.md)
|
||||
|
||||
# Building
|
||||
|
||||
This Android app is written in Java and is using the Gradle build system. To compile it, i recommend using Android Studio.
|
||||
@ -34,4 +38,4 @@ This Android app is written in Java and is using the Gradle build system. To com
|
||||
# Donations
|
||||
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>.
|
||||
|
||||
<a title="PayPal" href="https://www.paypal.me/andreaskaessens"><img src="https://raw.githubusercontent.com/stefan-niedermann/paypal-donate-button/master/paypal-donate-button.png" height="75" /></a>
|
||||
<a title="PayPal" href="https://www.paypal.me/andreaskaessens"><img src="https://raw.githubusercontent.com/stefan-niedermann/paypal-donate-button/master/paypal-donate-button.png" height="75" /></a>
|
||||
|
@ -1,15 +1,15 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
compileSdkVersion 30
|
||||
buildToolsVersion "29.0.3"
|
||||
|
||||
defaultConfig {
|
||||
applicationId "com.akdev.nofbeventscraper"
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 29
|
||||
versionCode 11
|
||||
versionName "0.4.1"
|
||||
targetSdkVersion 30
|
||||
versionCode 12
|
||||
versionName "0.4.2"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
@ -28,17 +28,17 @@ dependencies {
|
||||
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
|
||||
implementation 'androidx.recyclerview:recyclerview:1.1.0'
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
implementation 'androidx.navigation:navigation-fragment:2.3.0'
|
||||
implementation 'androidx.navigation:navigation-ui:2.3.0'
|
||||
implementation 'androidx.navigation:navigation-fragment:2.3.4'
|
||||
implementation 'androidx.navigation:navigation-ui:2.3.4'
|
||||
implementation 'androidx.appcompat:appcompat:1.2.0'
|
||||
implementation 'androidx.preference:preference:1.1.1'
|
||||
implementation "androidx.webkit:webkit:1.3.0"
|
||||
implementation "androidx.webkit:webkit:1.4.0"
|
||||
|
||||
// JSON save/restore shared preference
|
||||
implementation 'com.google.code.gson:gson:2.8.5'
|
||||
|
||||
// Theme
|
||||
implementation 'com.google.android.material:material:1.2.1'
|
||||
implementation 'com.google.android.material:material:1.3.0'
|
||||
|
||||
// Scraping
|
||||
implementation 'org.jsoup:jsoup:1.13.1'
|
||||
|
@ -0,0 +1,53 @@
|
||||
package com.akdev.nofbeventscraper;
|
||||
|
||||
import org.jsoup.Connection;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Element;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DocumentReceiver {
|
||||
|
||||
public static org.jsoup.nodes.Document getDocument(String url) {
|
||||
|
||||
org.jsoup.nodes.Document document;
|
||||
|
||||
try {
|
||||
// use default android user agent
|
||||
String user_agent = "Mozilla/5.0 (X11; Linux x86_64)";
|
||||
|
||||
Connection connection = Jsoup.connect(url).userAgent(user_agent).followRedirects(true);
|
||||
|
||||
Connection.Response response = connection.execute();
|
||||
|
||||
document = response.parse();
|
||||
|
||||
try {
|
||||
// accept cookies needed?
|
||||
Element form = document.select("form[method=post]").first();
|
||||
String action = form.attr("action");
|
||||
|
||||
List<String> names = form.select("input").eachAttr("name");
|
||||
List<String> values = form.select("input").eachAttr("value");
|
||||
|
||||
Map<String, String> data = new HashMap<String, String>();
|
||||
|
||||
for (int i = 0; i < names.size(); i++) {
|
||||
data.put(names.get(i), values.get(i));
|
||||
}
|
||||
|
||||
document = connection.url("https://mbasic.facebook.com" + action)
|
||||
.cookies(response.cookies())
|
||||
.method(Connection.Method.POST)
|
||||
.data(data)
|
||||
.post();
|
||||
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
return document;
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@ import android.os.AsyncTask;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -144,11 +143,9 @@ public class FbEventScraper extends AsyncTask<Void, Void, Void> {
|
||||
@Override
|
||||
protected Void doInBackground(Void... voids) {
|
||||
|
||||
try {
|
||||
// use default android user agent
|
||||
String user_agent = "Mozilla/5.0 (X11; Linux x86_64)";
|
||||
Document document = Jsoup.connect(url).userAgent(user_agent).get();
|
||||
Document document = DocumentReceiver.getDocument(url);
|
||||
|
||||
try {
|
||||
if (document == null) {
|
||||
throw new IOException();
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import android.os.AsyncTask;
|
||||
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -51,8 +50,8 @@ public class FbPageScraper extends AsyncTask<Void, Void, Void> {
|
||||
do {
|
||||
try {
|
||||
// use default android user agent
|
||||
String user_agent = "Mozilla/5.0 (X11; Linux x86_64)";
|
||||
Document document = Jsoup.connect(url).userAgent(user_agent).get();
|
||||
|
||||
Document document = DocumentReceiver.getDocument(url);
|
||||
|
||||
if (document == null) {
|
||||
throw new IOException();
|
||||
@ -80,7 +79,7 @@ public class FbPageScraper extends AsyncTask<Void, Void, Void> {
|
||||
int max = shared_prefs.getInt("page_event_max", 5);
|
||||
|
||||
if (event_links.size() < max) {
|
||||
// find "next page
|
||||
// find next page
|
||||
try {
|
||||
String next_url = document
|
||||
.getElementsByAttributeValueMatching("href", "has_more=1")
|
||||
|
@ -9,7 +9,7 @@
|
||||
<string name="button_add">Zum Kalender hinzufügen</string>
|
||||
<string name="tooltip_paste">Einfügen von Inhalten aus der Zwischenablage in das URL-Eingabefeld</string>
|
||||
<string name="preferences_url_setting">Welcher URL-Präfix ist zu verwenden?</string>
|
||||
<string name="preferences_url_setting_summary">Die Nutzung von mbasic.facebook.com ist stabiler und schneller. Die Verwendung von www.facebook.com funktioniert besser bei Ereignissen mit mehreren Instanzen und zeigt eine hochauflösende Vorschau an, geht aber irgendwann kaputt, wenn Facebook das klassische Design deaktiviert.</string>
|
||||
<string name="preferences_url_setting_summary">mbasic is am schnellsten, www lädt eine hochauflösende Vorschau und touch dient als zusätzliches Backup</string>
|
||||
<string name="error_clipboard_empty">Fehler: Zwischenablage leer</string>
|
||||
<string name="error_scraping">Fehler: Veranstaltungsdaten nicht gefunden</string>
|
||||
<string name="error_url">Fehler: URL ungültig</string>
|
||||
|
@ -2,11 +2,13 @@
|
||||
<!-- Reply Preference -->
|
||||
<string-array name="url_to_scrape">
|
||||
<item>mbasic.facebook.com</item>
|
||||
<item>touch.facebook.com</item>
|
||||
<item>www.facebook.com</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="url_prefix">
|
||||
<item>https://mbasic.</item>
|
||||
<item>https://touch.</item>
|
||||
<item>https://www.</item>
|
||||
</string-array>
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
<!-- Preferences -->
|
||||
<string name="preferences_scraper_header" translatable="false">Scraper</string>
|
||||
<string name="preferences_url_setting">Which URL prefix to use</string>
|
||||
<string name="preferences_url_setting_summary">"Using mbasic.facebook.com is more stable and faster. Using www.facebook.com works better with multiple instance events and will display a high resolution preview but will eventually break when Facebook disables the classic design."</string>
|
||||
<string name="preferences_url_setting_summary">"mbasic is the fastest, www loads high-res image preview, touch is an additional backup."</string>
|
||||
|
||||
<string name="preferences_events_header">Events</string>
|
||||
<string name="preferences_event_setting">Clear event list</string>
|
||||
|
2
fastlane/metadata/android/en-US/changelogs/12.txt
Normal file
2
fastlane/metadata/android/en-US/changelogs/12.txt
Normal file
@ -0,0 +1,2 @@
|
||||
- Fix scraping not working when cookies need to be accepted
|
||||
- Android 11 ready
|
Reference in New Issue
Block a user