Jump to content

Multiple arguments to multiple tabs in one query


Recommended Posts

  • 2 months later...

@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
  • 2 weeks later...

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

image.thumb.png.0a57be7e53a36d83d43fc144adf96697.png

 

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 

image.thumb.png.8a76616958d7ffca9ab82cfdb2648465.png

Link to comment

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...