Answer the question
In order to leave comments, you need to log in
What is the reason in the “write” mode it does not write to the record (an empty file), but in the “append” mode it is being written?
What could be the reason, there is no writing of one of the code blocks in the "write" mode, but there is a recording in the "append" mode? In two blocks with a "for" loop - one block has a record, the other does not. Perhaps this is due to the "try / except" block, perhaps it is impossible to write like this at all, because the record only goes from the last block. Those in the know please advise
with open('job_parser1.csv', "w", newline='') as csv_file:
csv_writer = writer(csv_file)
if x==0:
csv_writer.writerow(['Вакансия', 'Ссылка', 'Уровень заработной платы'])
for work in works_ua:
try:
work_ua_block = work.find('a').text
links = 'https://www.work.ua' + work.find('a').get('href')
new_links = str(links[0:-1])
price = work.find('div').find('b').get_text()
csv_writer.writerow([work_ua_block, new_links, price])
except (AttributeError, KeyboardInterrupt):
pass
for work in works:
work_block= work.find('a', class_="ga_listing").text
links = 'https://rabota.ua' + work.find('a').get('href')
price_rab_ua = work.find('span', class_="salary").get_text()
csv_writer.writerow([work_block, links, price_rab_ua])
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question