[WikipediaBridge] Update elements (#2167)

This commit is contained in:
岳东辰 2021-06-20 20:23:29 +10:00 committed by GitHub
parent 9c99a1a9c1
commit 5598fef3cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 10 deletions

View File

@ -140,12 +140,15 @@ class WikipediaBridge extends BridgeAbstract {
$anchorText = '...', $anchorText = '...',
$anchorFallbackIndex = 0){ $anchorFallbackIndex = 0){
// Clean the bottom of the featured article // Clean the bottom of the featured article
if ($element->find('div', -1)) if ($element->find('ul', -1))
$element->find('ul', -1)->outertext = '';
elseif ($element->find('div', -1)) {
$element->find('div', -1)->outertext = ''; $element->find('div', -1)->outertext = '';
}
// The title and URI of the article can be found in an anchor containing // The title and URI of the article can be found in an anchor containing
// the string '...' in most wikis ('full article ...') // the string '...' in most wikis ('full article ...')
$target = $element->find('p/a', $anchorFallbackIndex); $target = $element->find('p a', $anchorFallbackIndex);
foreach($element->find('//a') as $anchor) { foreach($element->find('//a') as $anchor) {
if(strpos($anchor->innertext, $anchorText) !== false) { if(strpos($anchor->innertext, $anchorText) !== false) {
$target = $anchor; $target = $anchor;
@ -216,11 +219,11 @@ class WikipediaBridge extends BridgeAbstract {
private function getContentsDe($html, $subject, $fullArticle){ private function getContentsDe($html, $subject, $fullArticle){
switch($subject) { switch($subject) {
case WIKIPEDIA_SUBJECT_TFA: case WIKIPEDIA_SUBJECT_TFA:
$element = $html->find('div[id=mf-tfa]', 0); $element = $html->find('div[id=artikel] div.hauptseite-box-content', 0);
$this->addTodaysFeaturedArticleGeneric($element, $fullArticle); $this->addTodaysFeaturedArticleGeneric($element, $fullArticle);
break; break;
case WIKIPEDIA_SUBJECT_DYK: case WIKIPEDIA_SUBJECT_DYK:
$element = $html->find('div[id=mf-dyk]', 0); $element = $html->find('div[id=wissenswertes]', 0);
$this->addDidYouKnowGeneric($element, $fullArticle); $this->addDidYouKnowGeneric($element, $fullArticle);
break; break;
default: default:
@ -253,7 +256,7 @@ class WikipediaBridge extends BridgeAbstract {
switch($subject) { switch($subject) {
case WIKIPEDIA_SUBJECT_TFA: case WIKIPEDIA_SUBJECT_TFA:
$element = $html->find('div[id=mp-tfa]', 0); $element = $html->find('div[id=mp-tfa]', 0);
$this->addTodaysFeaturedArticleGeneric($element, $fullArticle); $this->addTodaysFeaturedArticleGeneric($element, $fullArticle, -1);
break; break;
case WIKIPEDIA_SUBJECT_DYK: case WIKIPEDIA_SUBJECT_DYK:
$element = $html->find('div[id=mp-dyk]', 0); $element = $html->find('div[id=mp-dyk]', 0);
@ -270,11 +273,12 @@ class WikipediaBridge extends BridgeAbstract {
private function getContentsEo($html, $subject, $fullArticle){ private function getContentsEo($html, $subject, $fullArticle){
switch($subject) { switch($subject) {
case WIKIPEDIA_SUBJECT_TFA: case WIKIPEDIA_SUBJECT_TFA:
$element = $html->find('div[id=mf-artikolo-de-la-semajno]', 0); $element = $html->find('div[id=mf-artikolo-de-la-monato]', 0);
$element->find('div', -2)->outertext = '';
$this->addTodaysFeaturedArticleGeneric($element, $fullArticle); $this->addTodaysFeaturedArticleGeneric($element, $fullArticle);
break; break;
case WIKIPEDIA_SUBJECT_DYK: case WIKIPEDIA_SUBJECT_DYK:
$element = $html->find('div[id=mw-content-text]', 0)->find('table', 4)->find('td', 4); $element = $html->find('div.hp', 1)->find('table', 4)->find('td', -1);
$this->addDidYouKnowGeneric($element, $fullArticle); $this->addDidYouKnowGeneric($element, $fullArticle);
break; break;
default: default:
@ -288,11 +292,12 @@ class WikipediaBridge extends BridgeAbstract {
private function getContentsNl($html, $subject, $fullArticle){ private function getContentsNl($html, $subject, $fullArticle){
switch($subject) { switch($subject) {
case WIKIPEDIA_SUBJECT_TFA: case WIKIPEDIA_SUBJECT_TFA:
$element = $html->find('div[id=mf-uitgelicht]', 0); $element = $html->find('td[id=segment-Uitgelicht] div', 0);
$this->addTodaysFeaturedArticleGeneric($element, $fullArticle, 'Lees meer'); $element->find('p', 1)->outertext = '';
$this->addTodaysFeaturedArticleGeneric($element, $fullArticle, 'Lees verder');
break; break;
case WIKIPEDIA_SUBJECT_DYK: case WIKIPEDIA_SUBJECT_DYK:
$element = $html->find('div[id=mw-content-text]', 0)->find('table', 4)->find('td', 2); $element = $html->find('td[id=segment-Wist_je_dat] div', 0);
$this->addDidYouKnowGeneric($element, $fullArticle); $this->addDidYouKnowGeneric($element, $fullArticle);
break; break;
default: default: