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

  • Home
  • SEARCH
  • 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 8827917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:29:16+00:00 2026-06-14T07:29:16+00:00

This is my spider code class DmozSpider(BaseSpider): 5 name = dmoz 6 allowed_domains =

  • 0

This is my spider code

 class DmozSpider(BaseSpider):
  5     name = "dmoz"
  6     allowed_domains = ["dmoz.org"]
  7     start_urls = [
  8             "file:///home/ubuntu/xxx/test.html",
  9             ]
 10     def parse(self, response):
 11         hxs = HtmlXPathSelector(response)
 12         sites = hxs.select("//li")
 13         items = []
 14         for site in sites:
 15
 16             item = DmozItem()

 17             item['title'] = site.select('a/text()').extract()
 18             item['link'] = site.select('a/@href').extract()
 19             item['desc'] = site.select('text()').extract()
 20             items.append(item)
 21         return items

Now i want to write data in log file like name: {{name}} , link={{link }} for tetsing , as it crawls the site live.

how can i do that

  • 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-06-14T07:29:17+00:00Added an answer on June 14, 2026 at 7:29 am

    Here’s the answer, but I assume you just copied the code you already have, otherwise you’d know how to use file IO, or at least have the capability to research the topic which has been covered a million times on this site alone.

    ...
    item['title'] = site.select('a/text()').extract()
    item['link'] = site.select('a/@href').extract()
    item['desc'] = site.select('text()').extract()
    items.append(item)
    with open('log.txt', 'a') as f:
      f.write('name: {0}, link: {1}\n'.format(item['title'], item['link']))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

HI, I'm have this short spider code: class TestSpider(CrawlSpider): name = test allowed_domains =
The following code class SiteSpider(BaseSpider): name = some_site.com allowed_domains = [some_site.com] start_urls = [
below is my spider code, class Blurb2Spider(BaseSpider): name = blurb2 allowed_domains = [www.domain.com] def
This is the BaseSpider example from the Scrapy tutorial: from scrapy.spider import BaseSpider from
pipeline.py code class Examplepipeline(object): def __init__(self): dispatcher.connect(self.spider_opened, signal=signals.spider_opened) dispatcher.connect(self.spider_closed, signal=signals.spider_closed) def spider_opened(self, spider): log.msg(opened
This code works... $(document).ready(function(){ $('body').css('background','black'); }); but this code doesn't... $(document).ready(function(){ $('thumb_slider').css('background','black'); }); ^^^the
I'm trying to implement Orbit Slider in my homepage using this code: <script type=text/javascript
i have a jquery slider, link: http://ekallevig.com/jshowoff/ this is my html code: <div id=features>
i am trying to create slider movement graphics. The code explain better this. using
I am actually new to both spider monkey api and this mailing list. Actually

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.