Open a website list, extract the body content and save as .doc or .txt files

Can I use Uipath to copy the content of some web pages, then save as word doc file? How to do it?
thank you very much!

Hi @shiyatoo

If the data is in a table you can use Data scraping. If it is simply in html tags you can save the webpage as html, read it in as string then remove the tags via regex such as <[^>]*>, then use word activities to save to word file.

Kind Regards

I use “ctrl +S” to save the webpage, but there is nothing to return. it seems not work?
thank you very much!

save website.xaml (6.5 KB)

1 Like

Hey @shiyatoo

You are willing to save the website content by using Ctrl+S ?

Or

You want to save the contents of the website to a file ?

Thanks
#nK

save the website body content to .doc file

1 Like

Hey @shiyatoo

You can perform the below,

  1. Open the website using Open Browser activity

  2. Use Get Text activity with selector like this

<html app='chrome.exe' url='*yourDynamicURL*' />
<webctrl tag='BODY' />
  1. You need to save the output of the Get Text to a string variable

  2. Use Write Text File activity to create a ‘.txt’ file passing the above string variable which has the result of Get Text

  3. Hurray, your text file is ready with website content

If you want to save it to a doc file you need to just use word activities and write the same

Hope this helps you

Thanks
#nK

1 Like

1 Like

In the place of yourDynamicURL you need to replace it with either a dynamic URL variable you are using or the actual URL.

Thanks
#nK

In the field that says yourDynamicURL, type google.com/testtable for example.

text file is not the full website content?


save content of webpage.xaml (5.8 KB)

1 Like

Hey @shiyatoo

Try using Get Visible Text please…

Thanks
#nK

some body content is not visible?
And the same selector is error? :joy:
捕获

1 Like

Please enclose selector in double quotes.

Thanks
#nK

21.10.5+Branch.support-v21.10.Sha.369f46199a0fa6287d86ab2534b6896019db01bc

Source: Get Visible Text

Message: 捕获错误。

Exception Type: System.Runtime.InteropServices.COMException

RemoteException wrapping System.Runtime.InteropServices.COMException: 捕获错误。
at UiPath.Core.Activities.ScopeActivity.OnFaulted(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.Invoke(NativeActivityFaultContext faultContext, Exception propagatedException, ActivityInstance propagatedFrom)
at System.Activities.Runtime.FaultCallbackWrapper.FaultWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)

unfortunately,I still don’t find the solution :joy:
thanks very much!