python is doubling (" ") to ("" "") how can i fix this

3460 views python

This is an example of the code that i'm using without the website added.

from bs4 import BeautifulSoup
import requests
import csv
import random as rd
source = requests.get('').text
file = open('C:/xampp/htdocs/new-site/text.php', 'w')
soup = BeautifulSoup(source, 'lxml')
header = soup.find('p', class_='StoryHead').text
Program_Title = 'Program Title'
CSS = '<link rel="stylesheet" href="./css.css">'
start =  CSS + '<div id="yo">' + '<div id="first">' + '<h1>' + '\n' + '\n' + 
Program_Title + '\n' + header + '</h1>' + '</div id="first">'

csv_writer = csv.writer(file) 
csv_writer.writerow( start )

here: some of the results from the code, but as you can see the code doubles (" ")

"<link rel=""stylesheet"" href=""./css.css""><div id=""yo""><div id=""first""> 

answered question

1 Answer


This looks to be coming from escaping of the double quotes by the csv writer.


csv_writer = csv.writer(file, quoting=csv.QUOTE_NONE)

posted this

Have an answer?


Please login first before posting an answer.