vivis93
September 9, 2016, 8:42pm
1
From the link https://en.wikipedia.org/wiki/Alloa_Athletic_F.C. how to get :link of logo image , Ground link and Capacity from infobox.
So far i tried this
include("simple_html_dom.php");
//Wikipedia page to parse
$html = file_get_html('https://en.wikipedia.org/wiki/Alloa_Athletic_F.C.');
foreach($html->find('.label') as $element)
echo $element->href . "\n";
but no succes
Is the URL correct? According to Wikipedia, there is no such entry.
Scott
I get this with your link.
Scott
1 Like
Try this:
$aHtml = file('https://en.wikipedia.org/wiki/Alloa_Athletic_F.C.');
foreach($aHtml as $id => $element):
if( strpos($element, 'logo') ):
echo $id .':' .htmlspecialchars($element) . "<br><br>\n";
endif;
endforeach;
####Edit:
Results
46:<td colspan="2" style="text-align:center"><a
href="/wiki/File:Alloa_Athletic_FC_logo.png" class="image"><img
alt=""
src="//upload.wikimedia.org/wikipedia/en/thumb/c/c3/Alloa_Athletic_FC_logo.png/200px-Alloa_Athletic_FC_logo.png"
width="200" height="176"
srcset="//upload.wikimedia.org/wikipedia/en/thumb/c/c3/Alloa_Athletic_FC_logo.png/300px-Alloa_Athletic_FC_logo.png
1.5x,
//upload.wikimedia.org/wikipedia/en/thumb/c/c3/Alloa_Athletic_FC_logo.png/400px-Alloa_Athletic_FC_logo.png
2x" data-file-width="410" data-file-height="360"
/></a></td>
209:<div class="thumbinner" style="width:152px;"><a
href="/wiki/File:Alloa_Athletic_FC_logo.svg" class="image"><img
alt="A logo depicting a gold shield with black edges and a black wasp on
it. Below the shield, the words "Alloa Athletic F.C."
appear on a gold scroll banner."
src="//upload.wikimedia.org/wikipedia/en/thumb/3/38/Alloa_Athletic_FC_logo.svg/150px-Alloa_Athletic_FC_logo.svg.png"
width="150" height="105" class="thumbimage"
srcset="//upload.wikimedia.org/wikipedia/en/thumb/3/38/Alloa_Athletic_FC_logo.svg/225px-Alloa_Athletic_FC_logo.svg.png
1.5x,
//upload.wikimedia.org/wikipedia/en/thumb/3/38/Alloa_Athletic_FC_logo.svg/300px-Alloa_Athletic_FC_logo.svg.png
2x" data-file-width="437" data-file-height="307" /></a>
211:<div class="magnify"><a
href="/wiki/File:Alloa_Athletic_FC_logo.svg" class="internal"
title="Enlarge"></a></div>
625:<td class="mbox-image"><a
href="/wiki/File:Commons-logo.svg" class="image"><img alt=""
src="//upload.wikimedia.org/wikipedia/en/thumb/4/4a/Commons-logo.svg/30px-Commons-logo.svg.png"
width="30" height="40" class="noviewer"
srcset="//upload.wikimedia.org/wikipedia/en/thumb/4/4a/Commons-logo.svg/45px-Commons-logo.svg.png
1.5x,
//upload.wikimedia.org/wikipedia/en/thumb/4/4a/Commons-logo.svg/59px-Commons-logo.svg.png
2x" data-file-width="1024" data-file-height="1376"
/></a></td>
1285: <div id="p-logo" role="banner"><a class="mw-wiki-logo"
href="/wiki/Main_Page" title="Visit the main
page"></a></div>
Ok. The period was missing from your URL too John. I see the page now.
Scott
1 Like
Yes, I’ve just fixed the link in the first post. Discourse is discarding the final period as not being part of the URL.
vivis93
September 10, 2016, 10:15am
8
John_Betong:
thank you for response , it is possible to get only one link eg. that with dimensions width=“200” height=“176” I have marked with red the location of element.
Also for Ground i need the link of the stadium marked with red down.
And for Capacity the text
system
Closed
December 10, 2016, 5:15pm
9
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.