Dynamic url parameters loop and get label values of a webpages

studio

#1

website.com?S=P190&flag=1

Hello experts… I need open a new browser and pass the above url
by incrementing 1, like p191, p192,etc up to 2000 and flag=1(remain same)
and get the value of a webpage label’s, and pass the label’s values to excelsheet

may i know, how this can be achieved, im a new learner… appreciate your help on this…

Im using UIpath community studio…


#2

Hi,
Whats exactly do you means by webpage label? which field you want to scrape on the website?
Rest all is a simple workflow.


#3

Hi Thanks… just viewed the source of the html webpage
for eg: i need to capture customer mobile, which is below and being displayed on the webpage and in the similar way, we have name, address,etc… Thanks

Customer Mobile :   078863504

#4

Hi,

Here is the approach:

  • Open the website using Open Browser activity which is one time job

  • while loop set the expression like cnt<2000

  • Use Navigate To activity to opens up the url ("https://www.website.com/?S=P"+cnt.ToString+"&flag=1") in the same tab (p191,p192…p2000)

  • Increase the counter cnt+1 (default cnt=190)

  • Perform the scraping like name, address,etc store it in variable and pass to the excel.

  • Either use write cell or build the datatable to import the value to excel.

For the reference:


web2


#5

Thanks…

The workflow has validation errors. Review and resolve them first.

System.Activities.InvalidWorkflowException: The workflow has validation errors. Review and resolve them first. —> System.Activities.InvalidWorkflowException: The following errors were encountered while processing the workflow tree:
‘DynamicActivity’: The private implementation of activity ‘1: DynamicActivity’ has the following validation error: Compiler error(s) encountered processing expression “SpanCmobileLbl”.
‘SpanCmobileLbl’ is not declared. It may be inaccessible due to its protection level.

‘DynamicActivity’: The private implementation of activity ‘1: DynamicActivity’ has the following validation error: Compiler error(s) encountered processing expression “SpanCmobileLbl”.
‘SpanCmobileLbl’ is not declared. It may be inaccessible due to its protection level.

at System.Activities.Validation.ActivityValidationServices.ThrowIfViolationsExist(IList`1 validationErrors, ExceptionReason reason)
at System.Activities.WorkflowInspectionServices.CacheMetadata(Activity rootActivity, LocationReferenceEnvironment hostEnvironment)
at UiPath.Workflow.ViewModels.MainViewModel.IsWorkflowValid()
— End of inner exception stack trace —

im getting the above error

and also, im unable to find write cell, so that I can write to excel.

Appreciate your help on this… Thanks


#6

Hi,
You suppose to have excel activity by default but anyway please follow below post to install the packages from the package manager.

Regards to error message I can’t say much without workflow.
Could you please hover mouse over the blue balloon which show up the error in brief.


#7

Thanks…
image


#8

Hi,
Looks like you haven’t crated variable or may be it’s in different scope.
Please hit “Ctl+k” in the “Text” property and name the variable.


#9

thanks…i can able to get the only one phone in the text file(should I add any append), something wrong in the loop or my logic is wrong???


image


#10

Hi,
Because Default value of cnt set to 190108099 and in while loop you passing same hence it validate once.


#11

Thanks

I have set the default value is 190108090

so the values should increment like 190108091,92,93…to 99 in the loop for up to 9 times… so i need the phone no of 9 customers…which will add to the text file…

image


#12

Could you please attach workflow .


#13


image


#14

To add the phone numbers together / append, you could use Read text file right before you Get Text and store the contents to a string, then in the Write text file use stringfromfile+vblf+SpanCmobileLbl1, which will append the text as you write it.

Alternatively, you could store all the numbers to a string within the loop using Assign stringVariable=stringVariable+vblf+SpanCmobileLbl1 , then use the Write text file outside of the loop at the end.

You could also use .CSV as the extension in the Write text file and it will make it a table.


#15

Thanks


the message box im getting empty value.? any idea

Thanks


#16

Looks like get text returning null.
Please scrape again or use UiExplorer to find out the right selector and pass in get text.


#17

Thanks… Im getting the value in the loop i checked via messagebox, outside the loop the stringvariable is empty…


#18

Ok just change the scope of the variable from variable pane.
make it main scope/global scope.


#19

thanks a lot… it started working… i modified to csv file… im successful for capturing one field…

but i have more scrapper like name,address, atleast 5-10 fields. in a webpage…how to insert the same in the csv file…

appreciate your help on this…


#20

Hi,
Good. :slight_smile:
Yes you can insert as many value you want.
If field are less you could make use of write cell activity and pass the cell number.
Else build a data table and then pass that data table in “Write Range” activity which directly insert all the column at once.
You can find multiple solution in the forum to achieve it.
Please go through the UiPath academy in case you didn’t attend.
Its free. :slight_smile: