I am trying to add the option tag from a ppa, as to show on my own website the current Ubuntu distro's it support.
This is what i have so far.
<?php include 'https://launchpad.net/~gregory-hainaut/+archive/pcsx2.official.ppa#field.series'; ?>
this is the content of the option tag:
<select onchange="updateSeries(this);" size="1" name="field.series" id="field.series">
<option value="YOUR_UBUNTU_VERSION_HERE" selected="selected">Choose your Ubuntu version</option>
<option value="trusty">Trusty (14.04)</option>
<option value="saucy">Saucy (13.10)</option>
<option value="raring">Raring (13.04)</option>
<option value="quantal">Quantal (12.10)</option>
<option value="precise">Precise (12.04)</option>
<option value="lucid">Lucid (10.04)</option>
</select>
You'll want to use
file_get_contents(orcurl) to get the actual source code, and the parse it using (for instance)DOMDocument. For instance, you might try something like this:Fist define a function that lets us get the innerHTML of a node (thank you to Hiam):
Then get the contents and grab the select menu by ID
If I echo
$innerHTMLthe result is:From that result, you'll notice I only got the inner html of the select menu, so you'll want to wrap the returned innerHTML in a
selecttag:EDITS
The OP mentioned in comments that everything is working, but he wants a different select menu than the one selected above. Because the page he is scraping has invalid markup (two separate
selectmenus have the sameid) theDOMDocumentgetElementByIdcall is not fetching the correct node. To correct this you have to look at the DOM tree and fine a unique parent element so that you can first grab the parent node and then run a query to find the item you're looking for In this case, the menu that the OP wants is inside of adivwith an ID of "", so all we do is grab that node, and then usegetElementsByTagNameto grab the select menu: