Clean URLs from Google Search results

I am new to Make and hope someone can provide some assistance.

I need to createa scenario where a google search result will populate a google sheets page with urls from the search results.

I have successfully done this by using a HTTP module (gets the google search results url) then a text parsing module (extracts the links from the data) and then a Google Sheets module (to save the filtered urls) BUT the urls in the google sheet contain “/url?q=” at the beginning of the urls and also include “&” followed by other coding that is not part of the url.

I need to filter or replace the prefix /url?q= as well as the & and all text after the &

In essence, I need to change this…

/url?q=https://website.com/&sa=U&ved=2ahUKEwjNyNv9z7fdfdXHEFkFHUpsEK8QFnoECAUQAg&usg=Agggaw2opjkKEAUPzyKjTJnkzQyZ

into this…

https://website.com/

Appreciate any assistance.

Welcome to the Make community!

You can use the built-in function replace

e.g.:

/(?:\/url\?q=|&.+)/g

Proof https://regex101.com/r/jBVC8i/1

Output:

Screenshot_2024-11-01_141119


For more information, see Text Parser in the Make Help Center:

Match Pattern
The Match pattern module enables you to find and extract string elements matching a search pattern from a given text. The search pattern is a regular expression (aka regex or regexp), which is a sequence of characters in which each character is either a metacharacter, having a special meaning, or a regular character that has a literal meaning.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

Thanks. That helps. I ran it and it removed the exact single instance. How there are multiple results in the google search so how would I modify this so that it does the same for all urls when the urls are all different?

For instance:

/url?q=https://www.website.com;sa=U&ved=2ahUKEwiSrNOs37mJAxW7MVkFHTiBPCUQFnoECAQQAg&usg=AOvVaw0QQjNRcdF0FFbG0b98WrPJ" data-ved="2ahUKEwiSrNOs37mJAxW7MVkFHTiBPCUQFnoECAQQAg

/url?q=https://www.cnn.com/article1;sa=U&ved=VVVUKEwiSSSSSSW7MVkFHTiBPCUQFnoECAQQAg&usg=AOvVaw0QQjNRcdF0FFbG0b98WrPJ" data-ved="2ahUKEwiSrNOs37mJAxW7MVkFHTiBPCUQFnoECAQQAg

/url?q=https://www.bbcnews.com;sa=U&ved=QWQUKEwiSrNOs37mFFFW7MVkFHTiBPCUQFnoECAQQAg&usg=AOvVaw0QQjNRcdF0FFbG0b98WrPJ" data-ved="2ahUKEwiSrNOs37mJAxW7MVkFHTiBPCUQFnoECAQQAg

/url?q=https://wsj.com;sa=U&ved=UUUKEwiSrNOsCEEJAxW7MVkFHTiBPCUQFnoECAQQAg&usg=AOvVaw0QQjNRcdF0FFbG0b98WrPJ" data-ved="2ahUKEwiSrNOs37mJAxW7MVkFHTiBPCUQFnoECAQQAg

Thanks. This was helpful but only changed the first URL. My goal is to automate the creation of a a dynamic (growing) list of urls in a googlesheet. I am able to get the google search page results

I then connect a text parser to extract the links.

I then filter the results so I only get the 10 google results as opposed to the other google links that are found on the search results page.

I then save these results to a google sheet.

All of this works well, BUT the collected urls in the google sheet contain “/url?q=” at the beginning of the urls and also include “&” followed by other coding that is not part of the url.

I need to filter or replace the prefix /url?q= as well as the & and all text after the &.

I am assuming I can do this either before sending the urls to the google sheet or after but would appreciate further assistance.

I don’t see the replace function with the regex pattern I provided to you used anywhere in your screenshots.

Did you know, this forum has a Hire a Pro category, where you can post your request for off-site specialised help on other platforms (video call/screenshare/private messaging/etc.)? This may help you get your issue resolved faster especially if it is urgent. It is important to post your request in the Hire a Pro category, as forum members are not allowed to advertise their services (even offer FREE assistance to help) in other categories like here. Once you have posted in the Hire a Pro category, that will allow other members like me to provide booking links to our calendars for a free consultation and video assistance (including screenshare)!