Extract Session ID from URL using Jmeter - regex

I'm using jmeter to try and test a website. I'm currently having issues extracting information that is returned.
For instance I send a HTTP request to:
https://intranet.company.com/Capps/f?p=101:1:
The website responds with:
https://intranet.company.com/Capps/f?p=101:1:11016690116729:::::
The new string of numbers listed at the end of response is the session id that I must use to test other pages of the program. I've been trying to use a reg Ex extractor but I cannot seem to pull the number off the url. I am currently using jmeter 3.1
Regular Expressions I've tired:
f?p:101:1:([0-9]{16})::
f?p=([0-9]{1,3}):([0-9]{1,3}):([0-9]{16}):
And various similar expressions, but none have worked for me. If I set up the website with no session ids it will work, but the website is required to use session ids.
Thanks for any help you may provide,
Zwils0

You need to escape ? sign as it is a meta-character and might be interpreted as repetition pattern
For some reason you are trying to extract 16-digit long integer while your id is 14-digit long
I would suggest the following Regular Expression Extractor configuration:
Field to check: URL
Reference Name: anything meaningful, i.e. id
Regular Expression: f\?p=101:1:(\d+):
Template: $1$
Demo:
References:
Apache JMeter: Regular Expressions
Using RegEx (Regular Expression Extractor) with JMeter
Perl 5 Regex Cheat sheet

I don't know anything about jmeter, but I guess it supports standard regex syntax. In your regular expressions, you are expecting a numeric session id with a constant length of 16. However, the session id is not necessary 16 digits long. In your own examples, it has 14 digits. If I check the session length on my oracle apex cloud account, it is 13 digits long.
I guess you cannot rely on its constant length, therefore, try to use something like this:
f?p=([0-9]{1,3}):([0-9]{1,3}):([0-9]{10,16}):
Or even this:
f?p=([0-9]{1,3}):([0-9]{1,3}):([0-9]*):
Also check out the following link and scroll down a bit. Guru Jeff Kemp already did something like this.
https://jeffkemponoracle.com/2011/10/07/googlebot-apex-session-ids-and-cookies/

Chris Muir covered it in his comprehensive post on configuring jmeter specifically for APEX. It's dated, but I'm pretty sure it still holds up.
c) sessionId Regular Expression Extractor
f?p=([0-9]{1,3}):([0-9]{1,3}):([0-9]{16}):
http://one-size-doesnt-fit-all.blogspot.com.au/2010/05/configuring-apache-jmeter-for-apex.html
This appears to be what you've tried, but it seems like there may be other settings and considerations.

Related

Jmeter regex extractor alternate option for lookbehind

I am trying to extract the value of session id from the response header.Is there an alternate way other than using lookbehind in jemeter?
I verified my regex in regexformatter and its working as expected but as jmeter is not supporting lookbehind, the solution is not working for me.
Response header :
Expires: 0
X-Frame-Options: DENY
x-session-id: 1a5e099f-5234-4
X-Application-Context: test:8080
Regex used is:
(?<=x-session-id: ).{0,16}
Can someone help me with it?
As per Regular Expressions chapter of the JMeter User Manual:
Note that (?<=regexp) - lookbehind - is not supported.
So you can just use something like: x-session-id:\s+(.+) and it should work fine:
More information: Using Regular Expressions to Extract Tokens and Session IDs to Variables
The Regular Expression Extractor configuration should be this one:
Regex:
x-session-id: (.*)
Assuming that the last character in the session id will be digits. Then you can use the following. If you think the second group in session id will be digits then replace second \w+ with \d+ and it will serve the purpose. Let me know if you think the other dataset may fail this regex.
Regex:(?:\w+-\w+-\d+)
Seems like you have an understanding about Regex so not mentioning the explanation. Let me know if this does not work for you. I will try to come up with another approach but in that scenario please give more datasets. Good Luck.

Regular Expression Syntax for URL extraction

I need to extract the string to the right of the equal sign character in an Apache Jmeter project. I am not familiar with Regular Expression syntax at all, but I think this would be the easiest way to extract it. The url is: https://myserver.com:portnum/im;jsessionid=48E10C95151BFB84D795C90FBC31E8E6
I only need the string to the right of the equal sign, not including the equal sign. My question is, what regular expression should I use to extract the string? Thanks!
It is as simple as =(\w+)
Demo:
References:
JMeter - Regular Expressions
Using RegEx (Regular Expression Extractor) with JMeter
Perl 5 Regex Cheat sheet
Also be aware that there are "smarter" ways of handling JSESSIONID:
In case if it comes as a Cookie you can get its value via HTTP Cookie Manager
If it is being passed as an URL parameter you could use HTTP URL Re-writing Modifier

Extracting Value In Between Quotes - Regular Expressions

I'm trying to extract a request ID for running load testing on J Meter that I need to use for the subsequent HTTP requests. I'm using the regular expression extractor to do this.
I've been trying for hours and hours to extract the value inside single quotations and have not had any success. The response looks similar to this.
RequestDateTime='2/12/2017 7:19:49 AM' RequestID='1234567' Client="14232" etc...
I want the exact numbers with no quotations around it. The value should be 1234567
I've tried using RequestID='(.*?)' but it gives the entire string whereas I just want the value inside.
Use regular expression RequestID='(\d+)
Template $1$
Match 1
Looking into "RegExp" Tester mode of the View Results Tree listener your regular expression itself is fine:
So my expectation is that your Regular Expression Extractor configuration is not correct, you should get expected value if use something like:
Reference Name: anything meaningful, i.e. RequestID
Regular Expression: RequestID='(.*?)'
Template: $1$
You should be able to refer the extracted value as ${RequestID} later on. Extracted JMeter Variable(s) can be visualised using Debug Sampler
See How to Debug your Apache JMeter Script article to learn more about JMeter tests troubleshooting techniques.
So the following regular expression should do the trick: '(\d*)'
Then Insert a Debug Sampler into your thread so you can see the reference name. The variable you are looking for will have the following name: referencename_g0
The _g0 represents the first group that was matched. If the expression matches other chars in your response, simply use the variable with the correct group number. (e.g _g1 or _g2, etc).
Hope this helps!

How to write regular expression in nutch?

I am using Nutch for crawling web pages. I am getting problem in writing the regular expression.
It is working fine with the following configuration:
Seed url :
www.practo.com
(preceded with https:// )
Regex-urlfilter.txt:
+^https://www.practo.com/
But I want to fetch only specific pages such as pages that contain information about 'cardiologist'
Example: I want to fetch pages like:
www.practo.com/hyderabad/doctor/some-name-cardiologist
i.e. I want to fetch pages ending in certain keyword.
I am using following regular expression:
+^https://www.practo.com(/[a-z0-9]*)*cardiologist
Please help me out in writing the regular expression.
I got answer to my question. Problem was getting the correct regular expression.
+^(https|http)://([a-zA-Z0-9./-]+)cardiologist([a-zA-Z0-9-#?=])*
The following site help me a lot to get to the correct expression : https://regex101.com/
You ca use the following:
+^https://www\.practo\.com.*cardiologist

Using Regular Expression Match Type in Google Analytics to track my changing date URL a trackable goal

I would like to track a URL destination goal type in Google Analytics using a Regular Expression Match type.
I have a URL that is generated with a unique date that I want to setup as a goal.
Can someone help me verify what I'm doing wrong with the strings? I cannot get this to work in GA. Thank you.
Generated URL:
/products/usedleadestimator.aspx?ckSRC=030712success
Goal Tracking URL in Google Analytics W/ RegEx:
^/products/usedleadestimator\.aspx\?ckSRC=\[^/]*\success
Generated URL:
/products/newleadestimator.aspx?ckSRC=040712success
Goal Tracking URL in Google Analytics W/ RegEx:
^/products/newleadestimator\.aspx\?ckSRC=\[^/]*\success
I'm not sure how GA's 'goal tracking' works, but I believe the regular expression you're looking for is:
^/products/usedleadestimator\.aspx\?ckSRC=\d+success$
In your pattern, you had \success, which would have been interepreted as trying to match a space character followed by 'uccess'. I'm not sure why the slash was there in the first place!