Commit | Line | Data |
---|---|---|
9cf08a99 NR |
1 | package be.nikiroo.gofetch.support; |
2 | ||
3 | import java.io.IOException; | |
03dcf928 | 4 | import java.io.UnsupportedEncodingException; |
9cf08a99 | 5 | import java.net.URL; |
03dcf928 | 6 | import java.net.URLDecoder; |
9cf08a99 NR |
7 | import java.util.AbstractMap; |
8 | import java.util.ArrayList; | |
9 | import java.util.List; | |
10 | import java.util.Map.Entry; | |
11 | ||
12 | import org.jsoup.nodes.Document; | |
13 | import org.jsoup.nodes.Element; | |
14 | import org.jsoup.nodes.Node; | |
15 | ||
16 | /** | |
17 | * Support <a href="https://www.7sur7.be/">https://www.7sur7.be/</a>. | |
18 | * | |
19 | * @author niki | |
20 | */ | |
21 | public class SeptSurSept extends BasicSupport { | |
22 | @Override | |
23 | public String getDescription() { | |
b389651b | 24 | return "7sur7.be: Info, sport et showbiz, 24/24, 7/7"; |
9cf08a99 NR |
25 | } |
26 | ||
27 | @Override | |
28 | public void login() throws IOException { | |
29 | addCookie("pwrefr2", ""); | |
30 | addCookie("pwv-atXMVFeyFP1Ki09i", "1"); | |
31 | addCookie("pwg-atXMVFeyFP1Ki09i", "basic"); | |
32 | ||
33 | addCookie("pwv", "1"); | |
34 | addCookie("pw", "functional"); | |
35 | ||
36 | URL url = new URL("https://www.7sur7.be/7s7/privacy/callback.do" | |
37 | + "?redirectUri=/" + "&pwv=1" + "&pws=functional%7Canalytics" | |
38 | + "&days=3650" + "&referrer="); | |
39 | ||
40 | open(url).close(); | |
41 | } | |
42 | ||
43 | @Override | |
44 | protected List<Entry<URL, String>> getUrls() throws IOException { | |
45 | List<Entry<URL, String>> urls = new ArrayList<Entry<URL, String>>(); | |
46 | URL url = new URL("https://www.7sur7.be/"); | |
47 | urls.add(new AbstractMap.SimpleEntry<URL, String>(url, "")); | |
48 | ||
49 | return urls; | |
50 | } | |
51 | ||
52 | @Override | |
53 | protected List<Element> getArticles(Document doc) { | |
54 | return doc.getElementsByClass("clip"); | |
55 | } | |
56 | ||
57 | @Override | |
58 | protected String getArticleId(Document doc, Element article) { | |
59 | String id = article.attr("id"); | |
60 | if (id != null && id.startsWith("clip")) { | |
61 | return id.substring("clip".length()); | |
62 | } | |
63 | ||
64 | return null; | |
65 | } | |
66 | ||
67 | @Override | |
68 | protected String getArticleTitle(Document doc, Element article) { | |
03dcf928 NR |
69 | try { |
70 | return URLDecoder.decode(article.attr("data-title"), "UTF-8"); | |
71 | } catch (UnsupportedEncodingException e) { | |
72 | throw new RuntimeException("UTF-8 support mandatory in JVM"); | |
73 | } | |
9cf08a99 NR |
74 | } |
75 | ||
76 | @Override | |
77 | protected String getArticleAuthor(Document doc, Element article) { | |
78 | return ""; | |
79 | } | |
80 | ||
81 | @Override | |
82 | protected String getArticleDate(Document doc, Element article) { | |
83 | return article.attr("data-date"); | |
84 | } | |
85 | ||
86 | @Override | |
87 | protected String getArticleCategory(Document doc, Element article, | |
88 | String currentCategory) { | |
89 | Element parent = article.parent(); | |
90 | if (parent != null) { | |
91 | Element catElement = parent.previousElementSibling(); | |
92 | if (catElement != null) { | |
93 | return catElement.text(); | |
94 | } | |
95 | } | |
96 | ||
97 | return ""; | |
98 | } | |
99 | ||
100 | @Override | |
101 | protected String getArticleDetails(Document doc, Element article) { | |
102 | return ""; | |
103 | } | |
104 | ||
105 | @Override | |
106 | protected String getArticleIntUrl(Document doc, Element article) { | |
107 | return article.absUrl("href"); | |
108 | } | |
109 | ||
110 | @Override | |
111 | protected String getArticleExtUrl(Document doc, Element article) { | |
112 | return ""; | |
113 | } | |
114 | ||
115 | @Override | |
116 | protected String getArticleContent(Document doc, Element article) { | |
03dcf928 NR |
117 | try { |
118 | return URLDecoder.decode(article.attr("data-intro"), "UTF-8") | |
119 | .trim(); | |
120 | } catch (UnsupportedEncodingException e) { | |
121 | throw new RuntimeException("UTF-8 support mandatory in JVM"); | |
122 | } | |
9cf08a99 NR |
123 | } |
124 | ||
125 | @Override | |
126 | protected Element getFullArticle(Document doc) { | |
127 | return doc.getElementById("detail_content"); | |
128 | } | |
129 | ||
9cf08a99 NR |
130 | @Override |
131 | protected ElementProcessor getElementProcessorFullArticle() { | |
132 | return new BasicElementProcessor() { | |
133 | @Override | |
134 | public boolean ignoreNode(Node node) { | |
93255a7d NR |
135 | return node.attr("class").equals("read_more") |
136 | || "teas_emopoll".equals(node.attr("id")) | |
137 | || "teas_emopoll_facebook".equals(node.attr("id")) | |
138 | || "soc_tools".equals(node.attr("id")); | |
9cf08a99 NR |
139 | } |
140 | ||
141 | @Override | |
142 | public String isSubtitle(Node node) { | |
143 | if (node instanceof Element) { | |
144 | Element element = (Element) node; | |
93255a7d | 145 | if (element.tagName().equals("strong")) { |
9cf08a99 NR |
146 | return element.text(); |
147 | } | |
148 | } | |
149 | return null; | |
150 | } | |
151 | }; | |
152 | } | |
153 | ||
93255a7d NR |
154 | @Override |
155 | protected List<Element> getFullArticleCommentPosts(Document doc, URL intUrl) { | |
156 | return null; | |
157 | } | |
158 | ||
9cf08a99 NR |
159 | @Override |
160 | protected List<Element> getCommentCommentPosts(Document doc, | |
161 | Element container) { | |
93255a7d | 162 | return null; |
9cf08a99 NR |
163 | } |
164 | ||
165 | @Override | |
166 | protected String getCommentId(Element post) { | |
93255a7d | 167 | return null; |
9cf08a99 NR |
168 | } |
169 | ||
170 | @Override | |
171 | protected String getCommentAuthor(Element post) { | |
93255a7d | 172 | return null; |
9cf08a99 NR |
173 | } |
174 | ||
175 | @Override | |
176 | protected String getCommentTitle(Element post) { | |
93255a7d | 177 | return null; |
9cf08a99 NR |
178 | } |
179 | ||
180 | @Override | |
181 | protected String getCommentDate(Element post) { | |
93255a7d | 182 | return null; |
9cf08a99 NR |
183 | } |
184 | ||
185 | @Override | |
186 | protected Element getCommentContentElement(Element post) { | |
93255a7d | 187 | return null; |
9cf08a99 NR |
188 | } |
189 | ||
190 | @Override | |
191 | protected ElementProcessor getElementProcessorComment() { | |
e818d449 | 192 | return new BasicElementProcessor(); |
9cf08a99 NR |
193 | } |
194 | } |