Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6467917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:50:29+00:00 2026-05-25T05:50:29+00:00

currently I am working with scrapy , which is a web crawling framework based

  • 0

currently I am working with scrapy, which is a web crawling framework based on python. The data is extracted from html using XPATH . (I am new to python) To wrap the data scrapy uses items, e.g.

item = MyItem()

item['id'] = obj.select('div[@class="id"]').extract()

When the id is printed like print item['id'] I get following output

[u'12346']

My problem is that this output is not always in the same form. Sometimes I get an output like

"[u""someText""]"

This happens only with text, but actually there is nothing speciall with the text compared to other text that is handled corretly just like the ID.

Does anyone know what the quotation marks mean? Like I said the someText was crawled like all other text data, e.g. from

<a>someText</a>

Any ideas?

Edit:

My spider crawls all pages of a blog. Here is the exact output

[u'41039'];[u'title]

[u'40942'];"[u""title""]"]

...

Extracted with

item['title']   = site.select('div[@class="header"]/h2/a/@title').extract()

I noticed that always the same blog posts have this quotation marks. So they dont appear randomly. But there is nothing special to the text. E.g. this title produces quotation marks

<a title="Xtra Pac Telekom web'n'walk Stick Basic für 9,95" href="someURL">
    Xtra Pac Telekom web'n'walk Stick Basic für 9,95</a>

So my first thought was that this is because of some special chars but there arent any.

This happeny only when the items are written to csv, when I print them in cmd there are no quotation marks.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T05:50:30+00:00Added an answer on May 25, 2026 at 5:50 am

    python can use both single ‘ and double “ quotes as quotation marks. when it prints something out it chooses single quotes normally, but will switch to double quotes if the text it is printing contains single quotes (to avoid having to escape the quote in the string):

    so normally, it is printing [u'....'] but sometimes you have text that contains a ‘ character and then it prints [u"...."].

    then there is an extra complication writing to csv. if a string is written to csv that contains just a ‘ then it is written as it is. so [u'....'] is written as [u'....'].

    but if it contains double quotes then (1) everything is put inside double quotes and (2) any double quotes are repeated twice. so u["..."] is written as "[u""...""]". if you read the csv data back with a csv library then this will be detected and removed, so it will not cause any problems.

    so it’s a combination of the text containing a single quote (making python use double quotes) and the csv quoting rules (which apply to double quotes, but not single quotes).

    if this is a problem the csv library has various options to change the behaviour – http://docs.python.org/library/csv.html

    the wikipedia page explains the quoting rules in more detail – the behavuour here is shown by the example with "Super, ""luxurious"" truck"

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working on program that must read data from a XML stream
I am working on an application which is used to scrape data from an
Currently working in the deployment of an OFBiz based ERP, we've come to the
Im currently working with an API which requires we send our collection details in
Currently working on a Spring 2.5 web application, looks as if the business has
Currently working through a Teach Yourself WPF tutorial. Usually I can mentally convert from
I currently working on a project which uses Spree Cart and which has hence
Im currently working on a site which will contain a products catalog. I am
Im currently working on a Python/Pygame module to wrap some basic sprite animation. Animation
Currently working on something which uses ajax for some pagination. What I'm looking to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.