use of com.jsoup.nodes.Document in project User-Behavior-in-Facebook by abozanona.
the class ActivityLog method getActivityLogData.
private void getActivityLogData(final long date, String log_filter) {
final String userId = getSingleValue.getString("c_user", "");
String url = "https://mbasic.facebook.com/" + userId + "/allactivity?log_filter=" + log_filter;
url = "https://mbasic.facebook.com/" + userId + "/allactivity?log_filter=" + "cluster_11";
Log.d("ActivityLog", url);
new GetHtml(url) {
@Override
public void getHtmlListener(String html) {
final ArrayList<String> links = new ArrayList<>();
Document dom0 = Jsoup.parse(html);
int day = Integer.parseInt((String) DateFormat.format("dd", date));
int month = Integer.parseInt((String) DateFormat.format("MM", date));
int year = Integer.parseInt(((String) DateFormat.format("yyyy", date)).substring(2));
String _day = day + "";
if (day < 10)
_day = "0" + _day;
String _month = month + "";
if (month < 10)
_month = "0" + _month;
String divId = "#tlUnit_" + _month + "_" + _day + "_" + year;
Elements tlUnit = dom0.select(divId);
if (tlUnit == null) {
return;
}
Elements dom = tlUnit.select("a");
for (int i = 0; i < dom.size(); i++) {
if (!dom.get(i).hasAttr("href"))
continue;
String _link = dom.get(i).attr("href");
if (_link != null) {
_link = replaceWithHash(_link);
if (_link.length() != 0) {
links.add(_link);
}
}
}
if (links.size() != 0) {
String url = "https://fba.ppu.edu/submitStudyResults.php";
RequestQueue queue = Volley.newRequestQueue(MainActivity.instance);
StringRequest postRequest = new StringRequest(Request.Method.POST, url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
new DBHelper(context).setJsonData(links.toString());
Log.d("Response", response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
}) {
@Override
protected Map<String, String> getParams() {
String uuid = getSingleValue.getString("clientId", "");
if (uuid.equals("")) {
uuid = "mobile" + UUID.randomUUID().toString();
setSingleValue.putString("clientId", uuid);
}
JSONArray arr = new JSONArray();
for (int i = 0; i < links.size(); i++) arr.put(links.get(i));
String clientId = getSingleValue.getString("clientid", "");
if (clientId.equals("")) {
clientId = randomString();
setSingleValue.putString("clientid", clientId);
setSingleValue.apply();
}
Map<String, String> params = new HashMap<>();
params.put("clientId", clientId);
params.put("data", links.toString());
return params;
}
};
queue.add(postRequest);
}
}
};
}
use of com.jsoup.nodes.Document in project User-Behavior-in-Facebook by abozanona.
the class Parser method parseBodyFragment.
/**
* Parse a fragment of HTML into the {@code body} of a Document.
*
* @param bodyHtml fragment of HTML
* @param baseUri base URI of document (i.e. original fetch location), for resolving relative URLs.
*
* @return Document, with empty head, and HTML parsed into body
*/
public static Document parseBodyFragment(String bodyHtml, String baseUri) {
Document doc = Document.createShell(baseUri);
Element body = doc.body();
List<Node> nodeList = parseFragment(bodyHtml, body, baseUri);
// the node list gets modified when re-parented
Node[] nodes = nodeList.toArray(new Node[nodeList.size()]);
for (Node node : nodes) {
body.appendChild(node);
}
return doc;
}
Aggregations