1 package be
.nikiroo
.gofetch
.support
;
3 import java
.io
.IOException
;
5 import java
.util
.AbstractMap
;
6 import java
.util
.ArrayList
;
8 import java
.util
.Map
.Entry
;
10 import org
.jsoup
.nodes
.Document
;
11 import org
.jsoup
.nodes
.Element
;
12 import org
.jsoup
.nodes
.Node
;
15 * Support <a href="https://www.7sur7.be/">https://www.7sur7.be/</a>.
19 public class SeptSurSept
extends BasicSupport
{
21 public String
getDescription() {
22 return "7SUR7.be Info, sport et showbiz, 24/24, 7/7";
26 public void login() throws IOException
{
27 addCookie("pwrefr2", "");
28 addCookie("pwv-atXMVFeyFP1Ki09i", "1");
29 addCookie("pwg-atXMVFeyFP1Ki09i", "basic");
31 addCookie("pwv", "1");
32 addCookie("pw", "functional");
34 URL url
= new URL("https://www.7sur7.be/7s7/privacy/callback.do"
35 + "?redirectUri=/" + "&pwv=1" + "&pws=functional%7Canalytics"
36 + "&days=3650" + "&referrer=");
42 protected List
<Entry
<URL
, String
>> getUrls() throws IOException
{
43 List
<Entry
<URL
, String
>> urls
= new ArrayList
<Entry
<URL
, String
>>();
44 URL url
= new URL("https://www.7sur7.be/");
45 urls
.add(new AbstractMap
.SimpleEntry
<URL
, String
>(url
, ""));
51 protected List
<Element
> getArticles(Document doc
) {
52 return doc
.getElementsByClass("clip");
56 protected String
getArticleId(Document doc
, Element article
) {
57 String id
= article
.attr("id");
58 if (id
!= null && id
.startsWith("clip")) {
59 return id
.substring("clip".length());
66 protected String
getArticleTitle(Document doc
, Element article
) {
67 return article
.attr("data-title");
71 protected String
getArticleAuthor(Document doc
, Element article
) {
76 protected String
getArticleDate(Document doc
, Element article
) {
77 return article
.attr("data-date");
81 protected String
getArticleCategory(Document doc
, Element article
,
82 String currentCategory
) {
83 Element parent
= article
.parent();
85 Element catElement
= parent
.previousElementSibling();
86 if (catElement
!= null) {
87 return catElement
.text();
95 protected String
getArticleDetails(Document doc
, Element article
) {
100 protected String
getArticleIntUrl(Document doc
, Element article
) {
101 return article
.absUrl("href");
105 protected String
getArticleExtUrl(Document doc
, Element article
) {
110 protected String
getArticleContent(Document doc
, Element article
) {
111 return article
.attr("data-intro").trim();
115 protected Element
getFullArticle(Document doc
) {
116 return doc
.getElementById("detail_content");
120 protected List
<Element
> getFullArticleCommentPosts(Document doc
, URL intUrl
) {
121 return getSubCommentElements(doc
.getElementsByClass("comment-list")
126 protected ElementProcessor
getElementProcessorFullArticle() {
127 return new BasicElementProcessor() {
129 public boolean ignoreNode(Node node
) {
130 return node
.attr("class").contains("chapo");
134 public String
isSubtitle(Node node
) {
135 if (node
instanceof Element
) {
136 Element element
= (Element
) node
;
137 if (element
.tagName().startsWith("h")
138 && element
.tagName().length() == 2) {
139 return element
.text();
148 protected List
<Element
> getCommentCommentPosts(Document doc
,
150 return getSubCommentElements(container
.getElementsByClass("children")
155 protected String
getCommentId(Element post
) {
156 Element idE
= post
.getElementsByTag("a").first();
158 return idE
.attr("id");
165 protected String
getCommentAuthor(Element post
) {
166 // Since we have no title, we switch with author
171 protected String
getCommentTitle(Element post
) {
172 // Since we have no title, we switch with author
173 Element authorE
= post
.getElementsByTag("footer").first();
174 if (authorE
!= null) {
175 authorE
= authorE
.getElementsByTag("cite").first();
177 if (authorE
!= null) {
178 return authorE
.text();
185 protected String
getCommentDate(Element post
) {
186 Element idE
= post
.getElementsByTag("a").first();
188 Element dateE
= idE
.getElementsByTag("span").first();
190 return dateE
.attr("data-epoch");
198 protected Element
getCommentContentElement(Element post
) {
199 Element contentE
= post
.getElementsByClass("comment-content").first();
204 protected ElementProcessor
getElementProcessorComment() {
205 return new BasicElementProcessor() {
207 public boolean ignoreNode(Node node
) {
208 if (node
instanceof Element
) {
209 Element el
= (Element
) node
;
210 if ("h4".equals(el
.tagName())) {
220 private List
<Element
> getSubCommentElements(Element posts
) {
221 List
<Element
> commentElements
= new ArrayList
<Element
>();
223 for (Element possibleCommentElement
: posts
.children()) {
224 if (possibleCommentElement
.hasClass("comment")) {
225 commentElements
.add(possibleCommentElement
);
230 return commentElements
;