meeffe Posted October 9, 2019 Share Posted October 9, 2019 thanks @deanishe It was quick and easy I guess. Anyway check your paypal Thanks a ton again!;) Link to comment
deanishe Posted October 9, 2019 Share Posted October 9, 2019 Thank you. That's very generous of you! Link to comment
meeffe Posted December 9, 2019 Share Posted December 9, 2019 @deanishe what about this one? When we take this piece of code: <?php $args = explode("\n", $argv[1]); // loop through args foreach ($args as $arg) { // create the url $url = 'https://www.google.es/search?q=' . urlencode(trim($arg)); // open the url in the default browser shell_exec('open ' . escapeshellarg($url)); } ?> I would like this script to automatically add some word/s after // create the url $url = 'https://www.google.es/search?q=' . urlencode(trim($arg)); e.g. when I use this search query - "toronto raptors" I'm getting https://www.google.es/search?q=toronto+raptors but I would like to get https://www.google.es/search?q=toronto+raptors+match How to add "match" to the query below so it would be a main keyword+match // create the url $url = 'https://www.google.es/search?q=' . urlencode(trim($arg)); It's a noobie question but I don't know nothing about php sadly. Thanks, Michal Link to comment
deanishe Posted December 9, 2019 Share Posted December 9, 2019 Well, it's basically the same question you asked last time. $url = 'https://www.google.es/search?q=' . urlencode(trim($arg)) . '+match'; or $url = 'https://www.google.es/search?q=' . urlencode(trim($arg . ' match')); meeffe 1 Link to comment
meeffe Posted December 9, 2019 Share Posted December 9, 2019 thanks deanishe Last time .urlencode part was at the end. Thanks again. Link to comment
meeffe Posted December 18, 2019 Share Posted December 18, 2019 What did i do wrong here? <?php $args = explode("\n", $argv[1]); // loop through args foreach ($args as $arg) { // create the url $url = 'https://ahrefs.com/v3-keywords-explorer/google/it/overview?keyword=' . rawurlencode(trim($arg)) . ' match'; // open the url in the default browser shell_exec('open ' . escapeshellarg($url)); } ?> When I use above code with 2-or more words query e.g. "chicago bulls" I receive the following output - chicago%20bulls match When I use urlencode instead of rawurlencode %20 just transforms into "+" so thats not it How to modify the code above so that I will get Link to comment
deanishe Posted December 18, 2019 Share Posted December 18, 2019 Changing spaces to %20 or + in URLs is the correct behaviour. The problem is that you aren't changing the other space before "match". So the browser thinks your URL isn't properly encoded (because it isn't), and encodes it again for you. You need to do what I did above and either replace the space with a + yourself or include all the text in the call to urlencode(). Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now