Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. well your specific example is pretty easy and straight forward. You can catch both with just using any generic substring function like stripos. Where it gets tricky is when you want for example "500 49 blvd" to equate to "500 49 boulevard". For that, you will need to create a lookup table with aliases. And then that's not even getting into whether or not "500 49 st" should match against "500 4 9 st" or "49 500 st". In short, there's no perfect solution for what you want to do, but you can start with a lookup table for non-substring aliases (like the blvd example) and either loop through the aliases with stripos or implode them into an alternation expression in a preg_match pattern.
  2. The exact pattern will vary depending on what you are actually trying to match. For example if you want to find a certain whole word, you could do function isWordFound($haystack,$needle) { return (bool) preg_match('~\b'.$needle.'\b~',$haystack); } $string = "foobar"; $word = "foo"; echo isWordFound($string,$word); // output: false $string = "foo bar"; $word = "foo"; echo isWordFound($string,$word); // output: true
  3. To stay on the same page, you could either have the form action point to the same page or else you can have a separate script handle the form post/processing and then make an ajax call instead of submitting the form.
  4. it would be better for you to store a full timestamp or datetimestamp in your database (as a date/time type column) and then format it when retrieving to display it. SQL will be able to handle it better as far as indexing and performing queries.
  5. yeah...sounds like the problem here is that your definition of what a URL is and what the real definition of a URL is are 2 different things. If you want to go by your definition, AbraCadaver makes some good suggestions, though parse_url does have certain limits with its ability to parse. this comment offers a better parser.
  6. Sounds like on your server PCRE is not compiled with "--enable-unicode-properties" enabled. edit: and possibly also "--enable-utf8". Well, you aren't getting errors thrown at you so you prolly already have this one enabled. Check out this article: http://chrisjean.com/2009/01/31/unicode-support-on-centos-52-with-php-and-pcre/
  7. Nonetheless.. you don't just show up somewhere asking how to scrape someone else's site and expect it not to be taken as "I'm trying to steal someone else's content." It ranks up there with people posting "hack my site" threads. It is common knowledge that these sorts of questions almost certainly come from people trying to do things they shouldn't be doing. The legit people are the exception, not the norm. So it is on them to prove that they are legit, and I do not feel bad for assuming they are not legit unless proven otherwise. I mean come on.. it's like if some random dude came up to you and asked you for help breaking into a house and taking things. Not even saying he totally knows the owner and it's totally okay. I do not think it is unfair of me to assume he's a thief asking for help to steal something.
  8. Right. I get what you're saying, but when literally 99.999% of all cases of scraping another site involve people NOT getting "special permission" from the owner, I think my money is on thief. If someone were determined to get permission for that sort of thing, they should work with them to create a better method in the first place, like make an API to request the info from the server.
  9. Oh. See I thought he was posting his own info as a challenge for me to ban him. Now that I see that he's posting other people's info that visit his site, I see now that he is most certainly a hypocrite about the whole "being professional" thing.
  10. I think what he meant to say was "struggling to find someone shady enough to be willing to help"
  11. Well I'm sorry, but there's no professional way to say you're a bad person for wanting to steal someone else's content. And even if there was, I wouldn't say it that way..because why should I act professional towards someone trying to rob someone else? Also, this is a free, public help site. If you are looking for someone "professional" then go hire someone. However, I would think if someone were professional, they wouldn't be trying to steal other peoples' content, nor agree to be a part in it on any level. So IMO you and I obviously have 2 different ideas of what "professional" means. I think you're looking for the "mob" type, not the "business" type.
  12. well func_num_args() and func_get_args() work independently from the default values provided in the parameter definitions. Example: function myFunc($foo='bar') { $args = func_get_args(); if (!isset($args[0])) { echo 'user did not give a first argument, using default for $foo='.$foo; } else { if ($args[0]==$foo) { echo 'user gave a first argument and it is the same value as default. $foo='.$foo.' and $args[0]='.$args[0]; } else { echo 'user gave a first argument and it is not the same value as default. $foo='.$foo.' and $args[0]='.$args[0]; } } } echo myFunc(); // output the 1st echo in the function echo myFunc('bar'); // outputs the 2nd echo in the function echo myFunc('foobar'); // outputs the 3rd echo in the function So to handle the following scenarios: - check if user gave more or less arguments than you expect: use func_num_args - simply use default values if values aren't passed: provide default value in parameter definition - determine if $foo is default value or if user happen to pass same value as default: compare parameter to func_get_args (first param is element 0, etc.). Alternately you can not set a default value for your params in the param list, and put that logic within the function. Advantage of this is that you don't need to compare $foo with func_get_args()[0] : Example: function myFunc($foo) { // user did not pass a first argument if (!isset($foo)) { /* assign a default value to $foo or return an error or whatever you want */ } }
  13. if func_num_args() returns 2 then that means there are 2 arguments passed to your function. Additionally you can use func_get_args() to get the argument values passed to your function. I'm not sure what you mean by attributes vs. arguments?
  14. The code tries to make an object based on a class, but it can't find the class definition. So, somewhere in one of your files there should be something that looks like this, or similar: class Tools { // stuff } It is obviously not in config.inc.php, so either config.inc.php expects a file that defines it to be included, or else config.inc.php is included in some other file and that other file is expected to include it, so that config.inc.php can access it. I'm guessing this is some 3rd party script you picked up and can't get working. So, my guess is the include(s) are there, but you aren't pointing to the proper path/to/file/to/include. So we can't really help you with what your file paths should be, short of having full access to your files on your server.
  15. well if you want to get into what a login system should and should not do... he shouldn't be reading unencrypted passwords and usernames from a flatfile to begin with..
  16. Yes it's possible. Basically you take the form's action url and use that for your curl request. If the form is submitted with the GET method, you just attach form fields and values like a query string to the url. If the form is submitted via POST method, you need to use curl_setopt to set CURLOPT_POST to true and use CURLOPT_POSTFIELDS to pass the form data. You may also need to set CURLOPT_FOLLOWLOCATION true in case the form processing script performs a redirect, to allow for the curl request to follow it. You will also need to set CURLOPT_RETURNTRANSFER to capture the response of the curl request. If the form requires SSL connection, you will need to set additional parameters. If the form processing script looks at other things like user agent or cookies to determine if it's a bot trying to spam or other things required by the site, you may need to add additional settings to make it look more like a browser made the request. Then you will use curl_exec to perform the curl request and return the results from the server. Methods for scraping the results largely depends on what kind of results are returned and what you are trying to scrape. You may need to use the DOM parser you may need to use some regex. Orr..the site might try to be tricky and render stuff with javascript to deter scraping, in which case it will be really hard to get what you want, short of running the results through an html/js parser (like phantomjs).
  17. so you want to steal someone else's content and you don't know how? Perhaps you should change your username..
  18. based on the screenshot, that config.inc.php file is attempting to make an object of class "Tools" and it can't find the class anywhere. You probably forgot to include the file that defines it or else pointing to wrong path of the file that defines it.
  19. there is no enforced rule, but functions are usually named for what they do. For example that connect() example probably has code in it to connect to a database or socket and return a resource handle for the connection.
  20. They are called functions. They are usually defined as such: function DB() { // do something } // call the function DB(); They are also class methods, though the syntax is slightly different. Example: class myClass { public function DB() { // do something; } } // call it $myClass = new myClass(); $myClass->DB(); *usually* a function will accept arguments and return something. For example: function makeLink($url,$text) { if (isset($url)&&isset($text)) { return "<a href='$url'>$text</a>"; } return ''; } // provide url and text and get an html marked up link in return $link = makeLink('http://www.google.com','google!'); echo $link; // output: <a href='http://www.google.com'>google!</a>
  21. Sounds like you have a battle plan.
  22. Make sure to output proper headers if you want to send it directly back to user: header( 'Content-Type: text/csv' ); header( 'Content-Disposition: attachment;filename=someFile.csv' );
  23. If you want to save the file on your server, then if you want, you can return a link to the file to click. If you do not care about saving it to the server as a file, just the instructions in the comment link and it will return it back directly as a file to be output. It will open a dialog to the user to save or view it, same as directly clicking on any other yoursite.com/someFile.csv link
  24. javascript cannot save files. You can use javascript to grab the table data off the page and send it back to your server. You can do it via AJAX method if you want. Then you'd use php to just generate a file, you can use fputcsv (follow the example in the doc). If you do not want to save it to a file on your server, modify with this comment)
  25. Think about what you are trying to get. Read what getElementById does. Do you think it is going to give you the page language? page language will either be in the html tag or a meta tag, neither of which has an id attribute. You will need to use getElementsByTagName and then loop through them checking for appropriate attributes using getAttribute
×
×
  • 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.