Python Forum
Copy xml content from webpage and save to locally without special characters
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Copy xml content from webpage and save to locally without special characters
#14
I did login to server to do a quick test.
The problem i get when try to download .xml with Request,
is that when Selenium has a session cookies that do not automatically goes over to Requests if try to download.
Then can do like this to transfer session cookie over to Requests.
session = requests.Session()
selenium_cookies = driver.get_cookies()
# Add each Selenium cookie to the Requests Session
for cookie in selenium_cookies:
    session.cookies.set(cookie['name'], cookie['value'])

print(driver.current_url) # This most be a url with .xml ending
response = session.get(driver.current_url)
with open('test1.xml', 'wb') as file:
    file.write(response.content)
Pedroski55 and Nik1811 like this post
Reply


Messages In This Thread
RE: Copy xml content from webpage and save to locally without special characters - by snippsat - Mar-23-2024, 02:12 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Why is the copy method name in python list copy and not `__copy__`? YouHoGeon 2 334 Apr-04-2024, 01:18 AM
Last Post: YouHoGeon
  how to save to multiple locations during save cubangt 1 604 Oct-23-2023, 10:16 PM
Last Post: deanhystad
Question Special Characters read-write Prisonfeed 1 674 Sep-17-2023, 08:26 PM
Last Post: Gribouillis
  UPDATE SQLITE TABLE - Copy a fields content to another field. andrewarles 14 4,567 May-08-2021, 04:58 PM
Last Post: ibreeden
  Rename Multiple files in directory to remove special characters nyawadasi 9 6,563 Feb-16-2021, 09:49 PM
Last Post: BashBedlam
  copy content of text file with three delimiter into excel sheet vinaykumar 0 2,398 Jul-12-2020, 01:27 PM
Last Post: vinaykumar
  Remove escape characters / Unicode characters from string DreamingInsanity 5 14,015 May-15-2020, 01:37 PM
Last Post: snippsat
  Check for a special characters in a column and flag it ayomayam 0 2,085 Feb-12-2020, 03:04 PM
Last Post: ayomayam
  save content of table into file atlass218 10 10,107 Aug-28-2019, 12:12 PM
Last Post: Gribouillis
  Split pyscaffold project into packages locally mucrom 0 1,532 Aug-05-2019, 12:07 PM
Last Post: mucrom

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020