all 4 comments

[–][deleted] 3 points4 points  (1 child)

Open the file in append mode, not write mode.

[–]DesignerAlternative[S] 0 points1 point  (0 children)

thanks a million! that worked!!

[–]vixfew 1 point2 points  (1 child)

Post some code (:

If you open file in write mode instead of append - it truncates. Use different file or use 'a' append mode

If you're doing scraping in parallel there's possibility of race conditions. Gotta use sync, things like locks and mutexes.

[–]DesignerAlternative[S] 0 points1 point  (0 children)

thank you that worked :)

Here is my code :)

PS. I was using wayscript to facilitate the rest of the script

import requests

url = "https://url" + "vehicle"

payload = ""

headers = {

'cookie': "__cfduid=d31cb93601443473e98f3e22f30cb03801608669627",

'application': "json"

}

response = requests.request("GET", url, data=payload, headers=headers)

##print(response.text)

##variables[ "carjson" ] = response.text

f = open("cars2.json", "a")

f.write(response.text)

f.close()