Call oDesk.grab() method
List<LinkEntry> links = oDesk.grab();
for (int i = 0; i < links.size(); i++) {
logger.info("\r\n(" + (i + 1) + ")\r\n" + links.get(i).toString());
}
1 | List<LinkEntry> links = oDesk.grab(); |
2 | |
3 | for (int i = 0; i < links.size(); i++) { |
4 | logger.info("\r\n(" + (i + 1) + ")\r\n" + links.get(i).toString()); |
5 | } |
List<LinkEntry> links = oDesk.grab();
for (int i = 0; i < links.size(); i++) {
logger.info("\r\n(" + (i + 1) + ")\r\n" + links.get(i).toString());
}
LinkEntry class
public class LinkEntry {
public String url = "";
public String title = "";
public String desc = "";
public String toString() {
String tag = "\r\n";
tag += "Url: " + url + "\r\n";
tag += "Title: " + title + "\r\n";
tag += "Desc: " + desc + "\r\n";
return tag;
}
}
1 | public class LinkEntry { |
2 | |
3 | public String url = ""; |
4 | public String title = ""; |
5 | public String desc = ""; |
6 | |
7 | public String toString() { |
8 | String tag = "\r\n"; |
9 | tag += "Url: " + url + "\r\n"; |
10 | tag += "Title: " + title + "\r\n"; |
11 | tag += "Desc: " + desc + "\r\n"; |
12 | return tag; |
13 | } |
14 | |
15 | } |
public class LinkEntry {
public String url = "";
public String title = "";
public String desc = "";
public String toString() {
String tag = "\r\n";
tag += "Url: " + url + "\r\n";
tag += "Title: " + title + "\r\n";
tag += "Desc: " + desc + "\r\n";
return tag;
}
}
oDesk class
public class oDesk {
public static List<LinkEntry> grab() {
List<LinkEntry> tag = new ArrayList<LinkEntry>();
try {
String link = "https://www.odesk.com/api/profiles/v1/search/jobs.xml?page=0;50&sort=date_posted;D";
Document doc = Jsoup.parse(new URL(link), 60000);
Elements elements = doc.select("job");
Element element = null;
for (int i = 0; i < elements.size(); i++) {
element = elements.get(i);
LinkEntry job = new LinkEntry();
if (element.select("ciphertext").first() == null) continue;
job.url = "https://www.odesk.com/jobs/" + element.select("ciphertext").first().text();
job.title = element.select("op_title").first().text();
job.desc = element.select("op_description").first().text();
tag.add(job);
}
} catch (Exception e) {
logger.error("", e);
}
return tag;
}
}
1 | public class oDesk { |
2 | |
3 | public static List<LinkEntry> grab() { |
4 | List<LinkEntry> tag = new ArrayList<LinkEntry>(); |
5 | try { |
6 | String link = "https://www.odesk.com/api/profiles/v1/search/jobs.xml?page=0;50&sort=date_posted;D"; |
7 | Document doc = Jsoup.parse(new URL(link), 60000); |
8 | Elements elements = doc.select("job"); |
9 | Element element = null; |
10 | for (int i = 0; i < elements.size(); i++) { |
11 | element = elements.get(i); |
12 | LinkEntry job = new LinkEntry(); |
13 | if (element.select("ciphertext").first() == null) continue; |
14 | job.url = "https://www.odesk.com/jobs/" + element.select("ciphertext").first().text(); |
15 | job.title = element.select("op_title").first().text(); |
16 | job.desc = element.select("op_description").first().text(); |
17 | tag.add(job); |
18 | } |
19 | } catch (Exception e) { |
20 | logger.error("", e); |
21 | } |
22 | return tag; |
23 | } |
24 | |
25 | } |
public class oDesk {
public static List<LinkEntry> grab() {
List<LinkEntry> tag = new ArrayList<LinkEntry>();
try {
String link = "https://www.odesk.com/api/profiles/v1/search/jobs.xml?page=0;50&sort=date_posted;D";
Document doc = Jsoup.parse(new URL(link), 60000);
Elements elements = doc.select("job");
Element element = null;
for (int i = 0; i < elements.size(); i++) {
element = elements.get(i);
LinkEntry job = new LinkEntry();
if (element.select("ciphertext").first() == null) continue;
job.url = "https://www.odesk.com/jobs/" + element.select("ciphertext").first().text();
job.title = element.select("op_title").first().text();
job.desc = element.select("op_description").first().text();
tag.add(job);
}
} catch (Exception e) {
logger.error("", e);
}
return tag;
}
}
No comments:
Post a Comment