This is a migrated thread and some comments may be shown as answers.

Fiddler: Programmatically add word to Query string

14 Answers 1514 Views
Fiddler Classic
This is a migrated thread and some comments may be shown as answers.
nasekt
Top achievements
Rank 1
nasekt asked on 03 Sep 2014, 05:33 PM
I'm tired of manually adding "dog" every time I search the web.

For example:

I do not want the "dog" appearing in my search results

https://www.google.com/search?q=cat+-dog

https://www.google.com/search?q=baseball+-dog

I'm new to Fiddler,So please give me a good hint.

Thanks

14 Answers, 1 is accepted

Sort by
0
Eric Lawrence
Telerik team
answered on 03 Sep 2014, 06:21 PM
You edit the url using the oSession.fullUrl property inside the OnBeforeRequest handler.

See http://blogs.telerik.com/fiddler/posts/13-07-15/understanding-fiddlerscript for a good introduction to FiddlerScript, including details of how to manipulate the fullUrl property.


Regards,
Eric Lawrence
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
nasekt
Top achievements
Rank 1
answered on 03 Sep 2014, 07:04 PM
Another question:

I want to know,if I can hide  the words in  the search box 

http://i.stack.imgur.com/P3ZTz.jpg

Thanks.
0
Eric Lawrence
Telerik team
answered on 03 Sep 2014, 07:38 PM
Fiddler can modify the HTML response to make any change you like, including changing JavaScript or text on the page. However, there's no standard way to do this (every page on the internet works differently) and overall the task that you're embarking upon here is a bit silly.

Regards,
Eric Lawrence
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
nasekt
Top achievements
Rank 1
answered on 03 Sep 2014, 09:00 PM
I totally love the HTML response,Now I just want to scrape/hide  the word in the search box without changing the search results(specifically Google)

I know Fiddler can do this very easily,but I don't know where to start from? This task is important to me.

Thank you 

Looking forward to your reply.
0
Eric Lawrence
Telerik team
answered on 04 Sep 2014, 01:43 PM
Inside OnBeforeResponse, use the GetResponseBodyAsString() method on the Session object to get the response content as a string. This obviously works only for responses that are strings.

Use the utilSetResponseBody method to assign the body of the response to the string of your choosing.


Regards,
Eric Lawrence
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
nasekt
Top achievements
Rank 1
answered on 06 Sep 2014, 06:22 PM
Sorry for being dumb as a rock,but Fiddler does not add text to the URL.

0
Eric Lawrence
Telerik team
answered on 10 Sep 2014, 12:38 PM
Your screenshot is showing Fiddler adding the text to the URL. Note that when you change the URL this way, the browser doesn't know that it has changed; it only knows if you send back a HTTP/307 redirect that informs the browser of the new URL.

Another thing to be aware of is that the URL part including and after the # is called the "URL Fragment". URL Fragments are kept on the clientside and are never sent to the server. They're typically examined by clientside javascript (e.g. AJAX code) to perform operations without navigating the main page.

Regards,
Eric Lawrence
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
nasekt
Top achievements
Rank 1
answered on 10 Sep 2014, 12:53 PM

Another question:I’ve scripted it to append a string to the URL and when I keep issuing the request it keeps appending over and over again

In OnBeforeRequest function

if (oSession.uriContains("www.youtube.com/results?search_query=")) {

var sText = "+test1+test2+test3";

oSession.fullUrl = oSession.fullUrl + sText;
 }

visual info: http://imgur.com/oRp24Ux,RvxtQTO,LniAECS#0

How can I fix this ?

Thank you for your time

0
Eric Lawrence
Telerik team
answered on 10 Sep 2014, 10:43 PM
Your best bet for basic programming questions is a general purpose programming Q&A site like StackOverflow.

To prevent adding text to a string multiple times, one approach would be to check to see whether that text is already in the string before adding it.

Regards,
Eric Lawrence
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
nasekt
Top achievements
Rank 1
answered on 10 Sep 2014, 11:09 PM

Really sorry to bother you,

I will keep it small,Can I add JQuery code to fiddler?

var keywordInput = $('input[name="-adult"]');
$('input[name="SearchButton"]').click(function() {
window.location = 'http://example.com?kwd=' + encodeURIComponent(keywordInput.val());
});

Thank you for your time.



0
Eric Lawrence
Telerik team
answered on 11 Sep 2014, 05:20 PM
You could inject jQuery code into pages, although doing so would likely break them if they already used jQuery.

You can't use jQuery in Fiddler itself (e.g. in the script) since jQuery expects to run in the browser, and Fiddler isn't a browser.

Regards,
Eric Lawrence
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
nasekt
Top achievements
Rank 1
answered on 13 Sep 2014, 03:58 PM
Really sorry for crossposting, but your given answer from Stackoverflow is not working, it does not even append .

I tried it several times, but no luck. Please help me

if (oSession.uriContains("www.youtube.com/results?search_query="))
{
var str = oSession.fullUrl;
var sAppend = "+test1+test2+test3";
if (oSession.fullUrl.indexOf(sAppend, str.length - sAppend.length) !== -1)
{
oSession.fullUrl = str + sAppend;
}
}
0
nasekt
Top achievements
Rank 1
answered on 19 Sep 2014, 10:10 AM
Really sorry for the inconvenience, I know this is not the appropriate site to post, but it's urgent.

The problem with this code is that it appends string to the very end of the URL 


if (oSession.uriContains("&q="))
{
var str = oSession.fullUrl;
var sAppend = "+test1+test2+test3";
if (!oSession.uriContains(sAppend))
{
oSession.fullUrl = str + sAppend;
}
}


So, How can I place +test1+test2+test3 right next to search?q= ?

Example:www.google.co.uk/search?site=webhp&source=hp&q=+test1+test2+test3&aqs=chrome..69i57.1582j0j4&sourceid=chrome&es_sm=122&ie=UTF-8

I tried the below code, but it takes me to google+ site

if (oSession.uriContains("&q="))
{
var str = oSession.fullUrl.IndexOf("&q=") ;
var sAppend = "+test1+test2+test3";
if (!oSession.uriContains(sAppend))
{
oSession.fullUrl = oSession.fullUrl.Substring( 0,oSession.fullUrl.IndexOf("&q=")) + sAppend ;
}

}

Where did I go wrong?

Thank you for your time. 
0
nasekt
Top achievements
Rank 1
answered on 19 Sep 2014, 12:05 PM

if (oSession.uriContains("search?q=")) 

{
var str = oSession.fullUrl;
var sAppend = "+test1+test2+test3";
if (!oSession.uriContains(sAppend))
{
oSession.fullUrl = str.replace( "search?q=","search?q=+test1+test2+test3" );
}
}

This code works,but when I click Next page in google. It browser freezes completely. Any ideas?

Tags
Fiddler Classic
Asked by
nasekt
Top achievements
Rank 1
Answers by
Eric Lawrence
Telerik team
nasekt
Top achievements
Rank 1
Share this question
or