Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---------------------- index.html --------------------------------------
- <!doctype html>
- <html>
- <head>
- <meta charset="utf-8">
- <script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
- </head>
- <body>
- <select class="dropdown">
- <option value="creag meagaidh">Creag Meagaidh</option>
- <option value="glencoe" >Glencoe</option>
- <option value="lochaber" >Lochaber</option>
- <option value="northern cairngorms" >Northern Cairngorms</option>
- <option value="southern cairngorms" >Southern Cairngorms</option>
- <option value="torridon" >Torridon</option>
- </select>
- Output:
- <div id="container" >
- </div>
- <script type="text/javascript">
- //when dropdown changes
- $('.dropdown').change(function(e) {
- //get dropdown value
- var place = $('.dropdown').val();
- //send request to script to scrape HTML
- $.ajax({
- //location of script
- url: '/script.php?place=' + place,
- success: function(result){
- //ajax has succeeded
- alert("Ajax success");
- //insert result from script
- $("#container").html(result);
- }
- });
- });
- </script>
- <style>
- #container {
- width: 250px;
- height: 250px;
- border: 1px solid black;
- }
- </style>
- </body>
- </html>
- ---------------------------------- script.php -------------------
- <?php
- $data = file_get_contents('http://www.sais.gov.uk/page_'.str_replace(" ","%20",$_GET['place']).'.asp');
- $regex = '/Observed Weather Influences........(.+?)\W\Wp\W/';
- preg_match($regex,$data,$match);
- echo $match[1];
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement