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 8206791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:47:27+00:00 2026-06-07T08:47:27+00:00

i really need help to finish this task since it’s related to my research

  • 0

i really need help to finish this task since it’s related to my research and I’m new to python and scrapy .

*the task is to select all input field (type=text or password or file ) and store it’s (id) in back-end DB , besides the page link where this input belongs *

my code to select input fields

def parse_item(self, response):
    self.log('%s' % response.url)

    hxs = HtmlXPathSelector(response)
    item=IsaItem()
    item['response_fld']=response.url

    item['text_input']=hxs.select("//input[(@id or @name) and (@type = 'text' )]/@id ").extract()
    item['pass_input']=hxs.select("//input[(@id or @name) and (@type = 'password')]/@id").extract()
    item['file_input']=hxs.select("//input[(@id or @name) and (@type = 'file')]/@id").extract()

    return item

Database pipeline code :

class SQLiteStorePipeline(object):


def __init__(self):
    self.conn = sqlite3.connect('./project.db')
    self.cur = self.conn.cursor()


def process_item(self, item, spider):
    self.cur.execute("insert into inputs ( input_name) values(?)" , (item['text_input'][0] ), )
    self.cur.execute("insert into inputs ( input_name) values(?)" , (item['pass_input'][0]  ,))
    self.cur.execute("insert into inputs ( input_name) values(?)" ,(item['file_input'][0] ,  ))

    self.cur.execute("insert into links (link) values(?)", (item['response_fld'][0], ))

    self.conn.commit()
    return item

but i still get error like this

self.cur.execute("insert into inputs ( input_name) values(?)" , (item['text_input'][0] ), )
exceptions.IndexError: list index out of range

or database store only first letter !!

Database links table 
 ╔════════════════╗
 ║      links     ║ 
 ╠════════════════╣
 ║  id  │input    ║ 
 ╟──────┼─────────╢
 ║    1 │     t   ║ 
 ╟──────┼─────────╢
 ║    2 │     t   ║ 
 ╚══════╧═════════╝
Note it should "tbPassword" or "tbUsername"

ouput fron json file

{"pass_input": ["tbPassword"], "file_input": [], "response_fld":     "http://testaspnet.vulnweb.com/Signup.aspx", "text_input": ["tbUsername"]}
{"pass_input": [], "file_input": [], "response_fld": "http://testaspnet.vulnweb.com/default.aspx", "text_input": []}
{"pass_input": ["tbPassword"], "file_input": [], "response_fld": "http://testaspnet.vulnweb.com/login.aspx", "text_input": ["tbUsername"]}
{"pass_input": [], "file_input": [], "response_fld": "http://testaspnet.vulnweb.com/Comments.aspx?id=0", "text_input": []}
  • 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-07T08:47:30+00:00Added an answer on June 7, 2026 at 8:47 am

    You are getting IndexError because you try to get the first item in the list, which sometimes is empty.

    I would do it like this.

    The spider:

    def parse_item(self, response):
        self.log('%s' % response.url)
    
        hxs = HtmlXPathSelector(response)
        item = IsaItem()
        item['response_fld'] = response.url
    
        res = hxs.select("//input[(@id or @name) and (@type = 'text' )]/@id ").extract()
        item['text_input'] = res[0] if res else None # None is default value in case no field found
    
        res = hxs.select("//input[(@id or @name) and (@type = 'password')]/@id").extract()
        item['pass_input'] = res[0] if res else None # None is default value in case no field found
    
        res = hxs.select("//input[(@id or @name) and (@type = 'file')]/@id").extract()
        item['file_input'] = res[0] if res else None # None is default value in case no field found
    
        return item
    

    The pipeline:

    class SQLiteStorePipeline(object):
    
        def __init__(self):
            self.conn = sqlite3.connect('./project.db')
            self.cur = self.conn.cursor()
    
    
        def process_item(self, item, spider):
            self.cur.execute("insert into inputs ( input_name) values(?)", (item['text_input'],))
            self.cur.execute("insert into inputs ( input_name) values(?)", (item['pass_input'],))
            self.cur.execute("insert into inputs ( input_name) values(?)", (item['file_input'],))
    
            self.cur.execute("insert into links (link) values(?)", (item['response_fld'],))
    
            self.conn.commit()
            return item
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to convert this to python. I just really need help with
I really need help on this. I tried translating this Perl into Python, but
I really need help with this last part of my program. I need to
I Really need help in this ... I'm building an application where I need
I really need help this time - Joomla 2.5 and latest K2. I'm using
I really need help on this one. I am having a simple login form
I really need help here. I'm desperate at this point. I have NSOperation that
Hello i am new in android and i really need help with something. I
Sorry to bother again, but I really need help transforming this Python2 code into
I'm new to Perl and I really need help witch a specific issue. I

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.