Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

regular expressions in php

  • 07-03-2011 11:38PM
    #1
    Registered Users, Registered Users 2 Posts: 42


    Anyone know how to make regular expressions in php (extract info from one site and put it in mine) bypass proxy? Basically, I'm making a website for an assignment and need to get my reg exp working on the uni wifi. I have it working on wifi without proxy settings so it's my last step. Thanks


Comments

  • Registered Users, Registered Users 2 Posts: 452 ✭✭AwayWithFaries


    Try looking at cURL.

    Never used it myself but it has methods for dealing with proxies in PHP. Hopefully that will be of some use to you.


  • Registered Users, Registered Users 2 Posts: 2,347 ✭✭✭Kavrocks


    Regular expressions can't bypass proxies. Regular expressions are used on data so what you need to do is direct your request through the proxy and that solution would depend entirely on how you are retrieving the data (file).


  • Registered Users, Registered Users 2 Posts: 42 Marina-anseo


    $url ="http://www.example.com";
    $contents = file_get_contents($url);

    That's how I'm getting the file and then editing it with a series of preg_replace uses.


  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    $url ="http://www.example.com";
    $contents = file_get_contents($url);

    That's how I'm getting the file and then editing it with a series of preg_replace uses.
    I don't get it. Why are you editing the contents of the file?


  • Registered Users, Registered Users 2 Posts: 42 Marina-anseo


    Because it takes the whole html webpage in $url and I only want the headings and descriptions for upcoming events e.g. festivals. I then replaced the original table format with p tags etc to create a more suitable layout in my site.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 9,579 ✭✭✭Webmonkey


    Because it takes the whole html webpage in $url and I only want the headings and descriptions for upcoming events e.g. festivals. I then replaced the original table format with p tags etc to create a more suitable layout in my site.
    Ok then that makes more sense.

    And what have you got so far. Where's the problem?


  • Registered Users, Registered Users 2 Posts: 42 Marina-anseo


    I have everything working perfectly on a proxy free internet connection but its just when I'm using my uni internet, (which is what I'll have to use when demonstrating the project) where my data should be, there is just an orange box with a php error complaining about the file_get_contents($url); part of my code, however, I know its the proxy is causing this not an actual problem with my code.


  • Registered Users, Registered Users 2 Posts: 2,347 ✭✭✭Kavrocks


    Yes what you need to do is connect through the proxy. You can set that up using the function located at http://php.net/manual/en/function.stream-context-create.php there is an example by somebody for connecting through a proxy, just change their settings to the ones needed for your uni wifi.

    I hope that works :rolleyes:.


  • Registered Users, Registered Users 2 Posts: 42 Marina-anseo


    Kavrocks wrote: »
    Yes what you need to do is connect through the proxy. You can set that up using the function located at http://php.net/manual/en/function.stream-context-create.php there is an example by somebody for connecting through a proxy, just change their settings to the ones needed for your uni wifi.

    I hope that works :rolleyes:.

    Thank you, I can't test it until Monday but it looks right. :)


  • Registered Users, Registered Users 2 Posts: 2,347 ✭✭✭Kavrocks


    Anytime.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 42 Marina-anseo


    Works :D


Advertisement