Jump to content

preg_match question


Codemunkie

Recommended Posts

Hello.

 

I'm trying to use preg_match to get a large amount of data from a website, is it possible to do this? It's html so i was hoping for line breaks etc.

 

The site source is below, which is what i'm wanting to retrieve.

    <p><iframe width="560" height="315" src="http://www.youtube.com/embed/P_ocwVLv55Y?wmode=transparent" frameborder="0" allowfullscreen></iframe></p>
<p><strong><span style="text-decoration: underline;">New Skins in the Store</span></strong></p>
<ul>
<li>Royal Guard Fiora</li>

<li>Nightraven Fiora</li>
<li>Bladecraft Orianna</li>
</ul>
<p><strong><span style="text-decoration: underline;">PVP.net v1.55</span></strong></p>
<ul>
<li>Ranked Teams
<ul>
<li>Fixed a bug with the background on the Team Invite popup</li>
<li>Fixed a bug where Team status would be missing on the Team Profile</li>
<li>Fixed a bug where Ranked Team specific notifications would not send properly</li>
<li>Fixed several bugs with client side stat calculation and display</li>

</ul>
</li>
</ul>
<p> <strong><span style="text-decoration: underline;">League of Legends v1.0.0.135</span></strong></p>
<p> <strong>Fiora, The Grand Duelist</strong></p>
<ul>
<li><strong>Duelist (passive)</strong> - Fiora regenerates health over 6 seconds each time she deals damage. Striking champions will cause this effect to stack up to 4 times.</li>
<li><strong>Lunge</strong> - Fiora dashes forward to strike her target, dealing physical damage. Fiora can perform the dash a second time within a couple seconds at no mana cost.</li>

<li><strong>Riposte </strong>- Fiora's Attack Damage is increased. When activated, Fiora parries the next basic attack and reflects magic damage back to the attacker. Works against champions, monsters, and large minions.</li>
<li><strong>Burst of Speed</strong> - Fiora temporarily gains additional Attack Speed. Each basic attack or Lunge she lands during this time increases her Movement Speed. Killing a champion refreshes the cooldown on Burst of Speed.</li>
<li><strong>Blade Waltz (ultimate)</strong> - Fiora dashes around the battlefield to deal physical damage to enemy champions. Successive strikes against the same target deal less damage.</li>
</ul>
<p> <strong>Alistar</strong></p>
<ul>
<li>Triumphant Roar mana cost increased to 28/41/54/67/80 from 20/35/50/65/80</li>

<li>Unbreakable Will mana cost reduced to 100 from 150</li>
<li>Trample damage increased to 10-27 per second from 10-23</li>
</ul>
<p> <strong>Fizz</strong></p>
<ul>
<li>Base damage increased to 56 from 54</li>
<li>Armor per level increased to 3.4 from 3.1</li>
<li>Churn the Waters mana cost reduced to 100 from 150</li>
</ul>
<p> <strong>Galio</strong></p>

<ul>
<li>Idol of Durand damage range increased to 600 from 575</li>
</ul>
<p> <strong>Irelia</strong></p>
<ul>
<li>Fixed a particle issue with Transcendent Blades (Hotfixed 2/21)</li>
</ul>
<p> <strong>Jax</strong></p>
<ul>
<li>Fixed a bug where Grandmaster's Might passive attack canceled if the buff ran out during the attack animation</li>

</ul>
<p> <strong>Lee Sin</strong></p>
<ul>
<li>Sonic Wave base damage increased to 50/80/110/140/170 from 45/75/105/135/165 (Hotfixed 2/21 due to an unintended nerf in the Nautilus patch)</li>
</ul>
<p> <strong>Lux</strong></p>
<ul>
<li>Lucent Singularity
<ul>
<li>Now additionally grants vision while in flight to its destination</li>
<li>Now starts its cooldown when cast rather than when detonated</li>

<li>Cooldown increased to 10 seconds from 9</li>
<li>Now displays a buff showing how long Lucent Singularity will last until it automatically detonates</li>
</ul>
</li>
<li>Finales Funkeln
<ul>
<li>Now grants vision of the affected area during the spell and vision of enemy champions hit for a short duration afterwards</li>
<li>Lux can no longer use Flash while casting Finales Funkeln</li>
</ul>
</li>
</ul>
<p> <strong>Malphite</strong></p>

<ul>
<li>Granite Shield now shows a cooldown timer</li>
<li>Unstoppable Force
<ul>
<li>Area of effect radius on impact increased to 325 from 300</li>
<li>Malphite can no longer flash while using Unstoppable Force</li>
<li>Fixed a bug where Malphite would seem to hit the target but would not cause the effect</li>
</ul>
</li>
</ul>
<p> <strong>Miss Fortune</strong></p>

<ul>
<li>Strut now shows a cooldown timer</li>
</ul>
<p> <strong>Nocturne</strong></p>
<ul>
<li>Umbra Blades now has a passive cooldown timer like Ziggs and Shen</li>
</ul>
<p> <strong>Olaf</strong></p>
<ul>
<li>Axe Throw
<ul>

<li>Damage increased to 80-260 from 50-210</li>
<li>Scaling changed to +1.0 bonus AD from +0.5 total AD</li>
<li>Base cooldown reduced to 8 seconds from 10</li>
<li>Cooldown reduction for picking up the axe reduced to 4.5 seconds from 6</li>
</ul>
</li>
<li>Ragnarok now provides 30/45/60 Armor and Magic Resist instead of 20/30/40 flat damage reduction</li>
<li>Movement Speed increased to 325 from 320</li>
</ul>
<p> <strong>Poppy</strong></p>

<ul>
<li>Paragon of Demacia now shows you over its icon how many stacks you have</li>
</ul>
<p> <strong>Shen</strong></p>
<ul>
<li>Fixed a few bugs with ability sounds</li>
<li>The following changes were hotfixed out on 2/21:
<ul>
<li>Base armor reduced to 19 from 23</li>
<li>Vorpal Blade health scaling lowered to 1.5% from 2%</li>
<li>Feint Energy cost increased to 50 from 40 at all levels</li>

<li>Base shield value reduced to 70/115/160/205/250 from 70/120/170/220/270</li>
</ul>
</li>
</ul>
<p> <strong>Teemo</strong></p>
<ul>
<li>Health per level increased to 82 from 77</li>
<li>Move Quick's passive component now shows a cooldown timer</li>
<li>Noxious Trap arm time reduced to 1 seconds from 2</li>
</ul>
<p> <strong>Tristana</strong></p>

<ul>
<li>Explosive Shot cast range increased to 625 from 600</li>
</ul>
<p> <strong>Ziggs</strong></p>
<ul>
<li>Hexplosive Mines
<ul>
<li>Mana cost reduced to 70/80/90/100/110 from 80/90/100/110/120</li>
<li>Slow duration reduced to 1.5 seconds from 2</li>
<li>Damage from 2nd and subsequent mines reduced to 40% from 50%</li>
</ul>

</li>
<li>Fixed a bug where Ziggs' Mad Scientist skin was leaving particles on the map (Hotfixed 2/21)</li>
</ul>
<p> <strong>Items</strong></p>
<ul>
<li>Madred's Bloodrazor attack damage increased to 40 from 30</li>
</ul>
<p> <strong>General</strong></p>
<ul>
<li>Improved minimap visibility of turrets in Colorblind Mode</li>

<li>Colorblind announcement colors now reference blue (friendly) and purple (enemy) teams</li>
<li>Important items purchased by your team will now be called out in chat (Aura items, Sight and Vision Wards, top tier items, etc)</li>
<li>Champion Kill messages are now more specific</li>
<li>You can now activate a timestamp for game chat in the options menu</li>
<li>When colorblind mode is activated, movement cursor is included with new color scheme (was not before)</li>
<li>Announcer callouts no longer reference blue team/purple team, and instead should reference friendly/enemy team (ie. A friendly inhibitor is respawning soon/the enemy inhibitor has respawned)</li>
<li>Champions will now attempt to run home immediately when disconnecting, rather than attempting to Recall</li>
<li>Small monster camp sigils now restore up to 30 Mana in addition to Health</li>
<li>Small Golem camp

<ul>
<li>Movement Speed increased to 300 from 180</li>
<li>Medium Golem base damage increased to 59 from 54</li>
</ul>
</li>
<li>Fixed a bug where whisper messages were the wrong color</li>
</ul>
<p> <strong>Co-Op Versus AI</strong></p>
<ul>
<li>Added Blitzcrank bot to the roster of bots in Co-Op versus AI.</li>
<li>Improved bots' ability to last hit and reduced how much they push their lanes.</li>

<li>Reduced the amount of gold given to bots on Summoner's Rift Intermediate.</li>
<li>Added the ability for bots to call for help from nearby bots.</li>
<li>Improved the precision of skill shots and ground targeted AoE abilities.</li>
<li>Minor bug fixes with Leona, Lux, and Shyvana bots.</li>
</ul>
<p> <strong>Art</strong></p>
<ul>
<li>Fixed animation bugs on the following skins:
<ul>
<li>Toy Soldier Gangplank</li>

<li>Jade Dragon Wukong</li>
<li>Superb Villain Veigar</li>
<li>Headhunter Master Yi</li>
</ul>
</li>
</ul>
<p><a href="http://euw.leagueoflegends.com/board/showthread.php?p=6422811"><strong>Click here to comment</strong></a></p>

 

Here is my current php, that doesn't seem to work. (var p -> 'fiora-patch-notes')

$content = file_get_contents("http://na.leagueoflegends.com/news/" . $_GET['p']);
$regex = '#frameborder="0" allowfullscreen></iframe></p>
(.*?)
<p><a href="http://euw.leagueoflegends.com/board/showthread.php?p=#';
preg_match($regex, $content, $match, PREG_PATTERN_ORDER);
echo $match;

 

Note that my regex searches for the last bit of the first line, and the first bit of the last line in the page source. There's more source but i didn't see any point in posting it.

 

I know it's going to be something really obvious, i'm not used to working with preg match.

 

Thanks.

Link to comment
Share on other sites

It doesn't seem like Riot wants you to scrape their pages.

 

http://na.leagueoflegends.com/legal/termsofuse

F. Transmitting or facilitating the transmission of any content that contains a virus, corrupted data, trojan horse, bot keystroke logger, worm, time bomb, cancelbot or other computer programming routines that are intended to and/or actually damage, detrimentally interfere with, surreptitiously intercept or mine, scrape or expropriate any system, data or personal information;
Link to comment
Share on other sites

1)  Scraping this website is against their ToS and I'm therefore closing this thread.

 

2)  You must add modifiers after your closing delimiter to get your regex to match mulitple lines.  Specifically add an 'm'

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.