Scrapy infinite scroll without pagination urls - scrapy
Using Scrapy , Failed to scrap books title authors and links from infinite scroll bookstore www.aseeralkotb.com website, from devtools inspect, can't find links for next pages.The code
import scrapy
class booksSpider(scrapy.Spider):
name = 'books'
start_urls = [
'https://www.aseeralkotb.com/categories/%D8%B3%D9%8A%D8%A7%D8%B3%D8%A9',
]
def parse(self, response):
for book in response.css('div.flex.flex-col.items-center'):
yield {
'title': book.css('a:not([itemprop="author"])::attr(title)').get(),
'author': book.css('h5[itemprop=name]::text').get(),
'detailslinks': book.css('a[title]::attr(href)').re(r'.*books.*')
}
for link in book:
yield response.follow(link.get(),method='POST',callback = self.parse_links)
The website is sending Ajax request and response from API is json along with html. With scrapy, it's throwing response status 419 but with powerful requests module it's working.
from bs4 import BeautifulSoup as bs
import requests
session = requests.Session()
req_homepage = session.get('https://www.aseeralkotb.com/categories/%D8%B3%D9%8A%D8%A7%D8%B3%D8%A9')
soup_homepage = bs(req_homepage.content, "lxml")
for meta in soup_homepage.find_all('meta'):
if meta.get('name', None) == 'csrf-token':
token = meta['content']
data = {"fingerprint":{"id":"UejQB7Z1XFiSDQ3fb05D","name":"categories.books.index","locale":"ar","path":"categories/%D8%B3%D9%8A%D8%A7%D8%B3%D8%A9","method":"GET","v":"acj"},"serverMemo":{"children":{"product-purchase-UtqTb6t0gxWEo6ym20401":{"id":"ZyeTxCh4kmoo4uVFdgAL","tag":"div"},"product-purchase-qfh1S6g5Hqr2yK5p19255":{"id":"IKQCqiaMPBOUz2y9pulb","tag":"div"},"product-purchase-kcsVg5TIGPUm7uBX19253":{"id":"6IV59cn7CyPi4ZlGRSTZ","tag":"div"},"product-purchase-dpgMlpItsMT6QvBC18496":{"id":"G0FV4of9IwUwxN2n3orA","tag":"div"},"product-purchase-djH1nx7Dd1CqjN1Y18245":{"id":"YQY9oXuI80F9zJFUdypB","tag":"div"},"product-purchase-HlsxJBgDCurMZMJ718218":{"id":"lFR46ttmPcJLyBmsPR9t","tag":"div"},"product-purchase-iYHhJD8zFwVpmpV417621":{"id":"dwfj7y3wUh9GMZVVwvM7","tag":"div"},"product-purchase-yEBL5qWdHGmE0cdD17348":{"id":"DwEuSTw1Z2iOcvLsG1dR","tag":"div"},"product-purchase-knjkw2Oa8EncjoPh17074":{"id":"SwZE2176HaD1T0pxPdXI","tag":"div"},"product-purchase-Ce7TBXAPYZbgxvyG17068":{"id":"6UeQ1JImg9AbcI2MjEIv","tag":"div"},"product-purchase-yvOJtFHoJb4M6UxD16469":{"id":"roh9C9Z1U3LVdLsdoRPg","tag":"div"},"product-purchase-zwXX0znXxyZh1ChE16452":{"id":"aQW3CPDhlstTNhRZE5rF","tag":"div"},"product-purchase-YjWk9AseS4bFmf0A16451":{"id":"nhwCNKGwVYa1oBF4wZQF","tag":"div"},"product-purchase-f4jgVxc9M3UPULFQ16010":{"id":"agM3tBl7u3DujVagMkQf","tag":"div"},"product-purchase-kUIj358Zh59HVPtI15963":{"id":"ETXtvZi87WrByYRjpmXu","tag":"div"},"product-purchase-Fg1GaFl9Pntx4JZ115740":{"id":"6PR3Jkr5DVm5QfFWBlCa","tag":"div"},"product-purchase-PenVRhRXZxC7IC8b15511":{"id":"DNRe2AZjqoyTOB1A6sDb","tag":"div"},"product-purchase-pLaYFiLzVJb4M83j15409":{"id":"4Qd9qRflfMzAZIloUHld","tag":"div"},"product-purchase-w59GJbmTvLOlzMzb14799":{"id":"kBl8JNOxnsveu7FeHQQy","tag":"div"},"product-purchase-6DwBE3WETIFYKhdN12394":{"id":"SFfx5sZFVFM1f5KgH9Mn","tag":"div"},"product-purchase-f0U27L0WdrCmdqlN10180":{"id":"LgNzK1XCeJByevDb6poq","tag":"div"},"product-purchase-src1a3URLG9nJHaL10178":{"id":"Zi1ebeCyIrCtqRccwA53","tag":"div"},"product-purchase-EgUvPZAnQvWaYNW69259":{"id":"ziL2dLDBmFMuO4gDHXMo","tag":"div"},"product-purchase-ScLkhiY9GDAIx9Q08620":{"id":"jeQ8oGEJUr3PO0USYTpq","tag":"div"},"product-purchase-33v00TdKKU73hhy38041":{"id":"bBr4JLNXg1uX5iSZf8hj","tag":"div"},"product-purchase-LT345WWsWMGIvPuP7888":{"id":"3B4WCJ59UTTvTKqir9TG","tag":"div"},"product-purchase-rjL4YnQBMXTQNKfW6800":{"id":"4JIdTHJUB6xtOHmeaShS","tag":"div"},"product-purchase-mOsgHazcWpZkkVuj6769":{"id":"fP49Yqnm2jPIkyOdALce","tag":"div"},"product-purchase-xEdrRToHrJJaLnd56733":{"id":"DsVrI5clO75rbmndtcQh","tag":"div"},"product-purchase-d7lOpqgD8t1wJkln6505":{"id":"qBk8BN2BtperIcxGKEyz","tag":"div"},"product-purchase-EipwbWTn9Jeli9mD6492":{"id":"smxCuFfMttSiDhivuhVx","tag":"div"},"product-purchase-gYZcbi026JAJ2rI76482":{"id":"dLVtuM3kp2xQoUaUivW2","tag":"div"},"product-purchase-vcr70vd4N4GhmX3v5598":{"id":"FXohQdm6DsAsfiA7ky8D","tag":"div"},"product-purchase-ndg0avUkJyeaAjxr5597":{"id":"fPj75X6MGP1F9B8wCnbh","tag":"div"},"product-purchase-mmDxYaLyNp7tf1Ur5596":{"id":"vOyPfgp0xSDRDocvSkck","tag":"div"},"product-purchase-EJx6fHwdkQfs5HsV5464":{"id":"0Fwp6t0CvMWW4DKXrvl1","tag":"div"},"product-purchase-QqsQdaRZfLix4SFv5390":{"id":"GvHb7qpXU3ZbyT23IyCa","tag":"div"},"product-purchase-myb9iuvqnWPyZ9ZS5288":{"id":"CeO7EKkMVzLwCs2a4B8b","tag":"div"},"product-purchase-QLEcTNKMgEzLwj474399":{"id":"e8s5FCAzdjp3v2n2S17w","tag":"div"},"product-purchase-33APh2rbpMr3CoLw4366":{"id":"6IncxfWnql9Ry3iKh50K","tag":"div"},"product-purchase-J6G2R5WjaANyoBvO3802":{"id":"DPspcwFWY0YsXBhNylDK","tag":"div"},"product-purchase-FNULLNL7NsfDL2iU3372":{"id":"itmEuicd6tSGTYfyeT92","tag":"div"},"product-purchase-aKfSCnbU75ingBoz3369":{"id":"OqY8jDBJfFZPb3PF6WF3","tag":"div"},"product-purchase-Hzkxb8cQW839i1BF3358":{"id":"Hww5WUf3yF7cl64FpSrU","tag":"div"},"product-purchase-yYiQW4FoZVQaIj0f3347":{"id":"wkidC4ZjSFpD4S3znzWp","tag":"div"},"product-purchase-EUSO3tzNJWz82pro3339":{"id":"40i3nSqkXeoxqiHSeory","tag":"div"},"product-purchase-8p7VIhbPdlhdu7Vv3338":{"id":"ndAIGfRABihmt0u7IT0T","tag":"div"},"product-purchase-hx28ANKENTuaVKpf3336":{"id":"yrkVeL3pR4IYkygrhdu8","tag":"div"},"product-purchase-MFdCqZvvHPrO5wUF2596":{"id":"y9C5kpMtxN4Dvstjgmlf","tag":"div"},"product-purchase-ZuVNZD15YHAjyeXZ2312":{"id":"gGvw2omCzLl3hk1s4Gab","tag":"div"},"product-purchase-rRIesRZpv9DwUc4l2270":{"id":"GNnC209aFE4basog52gW","tag":"div"},"product-purchase-Uxcb1TGqlJ0qsl422263":{"id":"WYCC1IkMz4CFZXPhuoJv","tag":"div"},"product-purchase-MPxl1tSpOr1gFK132257":{"id":"TVMlPCpaRgOnKBF7E8at","tag":"div"},"product-purchase-TKUDRMQ5LQr2vPOH2256":{"id":"Z1SYSyBBJcJ5xDRJIq3K","tag":"div"},"product-purchase-clf0iKNNxbF3RP8S2246":{"id":"7L8LgAOrczfS5AEdR3Qk","tag":"div"},"product-purchase-Xm3U4jdGlnAqvyoL1068":{"id":"9JG1ldDPPSXooHAajlFx","tag":"div"},"product-purchase-eMpapFY3p5ovgN041011":{"id":"Q6qvzqqp3iRs20ddgEz2","tag":"div"},"product-purchase-MT0TvvJugLIPYoty733":{"id":"cdIo3ldJVSq5YhMnntK2","tag":"div"},"product-purchase-MiBlkeqoVQxZBm5T709":{"id":"lY0m5u5Utv1fApfe9gkU","tag":"div"},"product-purchase-00S4TJP3KwpW2LGE163":{"id":"aPrcqxInNQvTwxP0VXl3","tag":"div"},"product-subscribe-yRzy0FkZdLWdo7XR20773":{"id":"VmbEwrO7kHes9PKxocZB","tag":"a"},"product-subscribe-1mWTBfEM7P467JGk20758":{"id":"WQd4NZaN33sFWLwf5K1n","tag":"a"},"product-subscribe-r6WSTnxHwvXFvBwT20751":{"id":"4IDg4SjaZZ5IVMXIZLvj","tag":"a"},"product-subscribe-eIoK1MoaJpqxYnE820738":{"id":"VhDO4mLwF6VuBnxVQeud","tag":"a"},"product-subscribe-ocj4Dg5pkeMF6dlc20514":{"id":"jIpA3NgdMt5mKOrfUFBY","tag":"a"},"product-subscribe-5vQrM5G6bRWr3sdF20309":{"id":"WPin6VpzPMSTYJnHVHnc","tag":"a"},"product-subscribe-3dtA2RrYwf6eyjQJ18758":{"id":"vJyb3HjOHnjtd46eVBDd","tag":"a"},"product-subscribe-Zm9XK65Bs5hh3FnM18564":{"id":"8pztwlfBC2rtEJWdlCaq","tag":"a"},"product-subscribe-XTolx99rODPjIgtv16986":{"id":"dwheNGnH965gp9WDKsOr","tag":"a"},"product-subscribe-l2VIqWTmf87ZgqtD16828":{"id":"9DLlD5UFuZxxWwz2jsbO","tag":"a"},"product-subscribe-zYBxqCjwnKDu3yMp15939":{"id":"uL9sPDEdiG2r9oOzyIYQ","tag":"a"},"product-subscribe-sLigK9XqznyCgecf15829":{"id":"gT4u0yu2VQ1qvJDKcYLV","tag":"a"},"product-subscribe-GbUoDex2mywBdcFj15817":{"id":"SHrtQLBimqKUdi2OoRcH","tag":"a"},"product-subscribe-JlN9RokXNnQLOdGe15784":{"id":"PYkTYi4jGUllClA2DhJb","tag":"a"},"product-subscribe-gPjML6fVlHyUj2Ii15763":{"id":"ZE4K9qaU0zTJQUFgcEBX","tag":"a"},"product-subscribe-sJ6a8Ol57MjVr1VS15746":{"id":"D1oct0mExCsYlfnLpT3Y","tag":"a"},"product-subscribe-ei8K00jzGzyw0OAx15340":{"id":"moj8AU8ITJzjNNw3G4A3","tag":"a"},"product-subscribe-L6oPtzwTcOWK1lx315140":{"id":"YgYJ8QcMjJpMvEsYHIMy","tag":"a"},"product-subscribe-Lm7CewNrWqGydq5O15131":{"id":"8za2SqoS5df7rhR7OAzw","tag":"a"},"product-subscribe-GYsBLhYUgYKqSWPJ15113":{"id":"1oV4nPzGpO6yjWw3yv4W","tag":"a"},"product-subscribe-GZKGeEu4f4dvL2mf15112":{"id":"xLeCbMlKgU9bK7p30mMs","tag":"a"},"product-subscribe-aR6LZDzdIjscTZ6915111":{"id":"x8e9qCpRYIMfX9sYtWTv","tag":"a"},"product-subscribe-XpXcVBMlQes7SWZD15110":{"id":"ZwM81qTpWoz4o2SJrurN","tag":"a"},"product-subscribe-sL1akvAsI0L9M6Sp15109":{"id":"qerkCyPGdTqI50nfJVoQ","tag":"a"},"product-subscribe-ZFL5h89noWths4Pw15108":{"id":"FHELi6vbygpbXj7Bz5hH","tag":"a"},"product-subscribe-1rUWoausOxjfJvxe15103":{"id":"6bZbg6z4Rdwc44IPSIml","tag":"a"},"product-subscribe-R5LPt0IzebR9CToS15102":{"id":"UBBJDrcglaDdOodkzIw6","tag":"a"},"product-subscribe-4wFgoWyjcyKK99sn15101":{"id":"Jcus3pKf5XRMhJjYlDbh","tag":"a"},"product-subscribe-ZKIySkqwWyJRUGSs15100":{"id":"NnRRovqaJBxufzpmnCMT","tag":"a"},"product-subscribe-yvTcT83IDrNlTWVh15075":{"id":"oTGJT5zdZhirdTBUhlwv","tag":"a"},"product-subscribe-jYkAw18TU2kKucyX15074":{"id":"1NjVteiNou2cqsZlrEPf","tag":"a"},"product-subscribe-v6s8a3Ly9FG43W3A15073":{"id":"QWR927Zsuqg84db2KruG","tag":"a"},"product-subscribe-k5TBn2yPgSrstwLZ15072":{"id":"bi7leKZWdvnuUkMilp4J","tag":"a"},"product-subscribe-6T365pFVLQdMVmDZ15060":{"id":"LfuUmRRA2js9GoC0L2Nx","tag":"a"},"product-subscribe-ZHQGi0hxGzAHJ39A15059":{"id":"ZemHtbGEerLcoitho0RD","tag":"a"},"product-subscribe-HE50lRzpS5AgStYb15057":{"id":"6M2Rka0WINDr4PYGZZ3M","tag":"a"},"product-subscribe-bT35k73z60Ed9yY915045":{"id":"3uQt7GU9Uo3tyORYAMil","tag":"a"},"product-subscribe-SPO0MvNJuabC6NAp15043":{"id":"0m8r2tEPDoIyAtBYjzWV","tag":"a"},"product-subscribe-WvCz6mOPZZMLDMKP15042":{"id":"rfngJqbQp6DsQKX62m3g","tag":"a"},"product-subscribe-vSvxWf8pytHJN9pp15041":{"id":"zpsSYqJuKaf7lyXGvCVL","tag":"a"},"product-subscribe-HvUSSwU9aLtdwERi15026":{"id":"65bRSZdGU2BiXvOPvK1M","tag":"a"},"product-subscribe-JoBhsEYknTwCNQO615025":{"id":"nGLJb3g4dfgFyLG1E2RP","tag":"a"},"product-subscribe-UmEYlSKPPsPycaVX15024":{"id":"LKo35Zluk4e0Koj68rPq","tag":"a"},"product-subscribe-UsvB6PTbFfAoI9hx15023":{"id":"lC4lOpZw4Lh9MPt2qpkP","tag":"a"},"product-subscribe-I1WyE6ufwQ9G1Ft515022":{"id":"x0JDVCXur1mMgF8dIt3w","tag":"a"},"product-subscribe-y7y2MxFlWFUbAMbM15021":{"id":"k87Sszv2eGTeTsPUiBzh","tag":"a"},"product-subscribe-FlzEb2POwkiguiUI15020":{"id":"BLGlCiJ1szZrlHpiP7ZQ","tag":"a"},"product-subscribe-g4vTMLyzwuIkVadn15019":{"id":"ciCtorj47jS3d8wUFejC","tag":"a"},"product-subscribe-QQeLYvJ8VFxEEntJ15017":{"id":"mzFB1B82fUE9kUv8WEl8","tag":"a"},"product-subscribe-ikCVKwzLPe1u7b5w15016":{"id":"cfxQ1ZWKs0wKx2yMF5bK","tag":"a"},"product-subscribe-N6NxXqB6HFevy1nz15014":{"id":"z4URc41Su7sUgWvteelw","tag":"a"},"product-subscribe-ueCdo719n5SvnyfP15012":{"id":"Ht7GXRGEG4hkUmiHt84A","tag":"a"},"product-subscribe-qpmviK0UvlJcHEqG15011":{"id":"CJwyMYE2bXbbQOBsEnYk","tag":"a"},"product-subscribe-85Ua7zLrK9AleFjK14954":{"id":"ML4Vb5woaOYnShZ9dqQO","tag":"a"},"product-subscribe-PKq65IoGJ1PyUD1x14953":{"id":"mt01jkD5c4DFpMfA4NGk","tag":"a"},"product-subscribe-FtAxVQtqbs8TaYoL14951":{"id":"FZhNs0Q21dVZLpYuQlDW","tag":"a"},"product-subscribe-JhA1CePxtb24Gvju14948":{"id":"SbI5buYEza9VHqelZe0y","tag":"a"},"product-subscribe-yeLjGuGtngHDYKwX14947":{"id":"PnQm4Xbmn4AmaLOa6G5p","tag":"a"},"product-subscribe-2bxzRKWUCmiI6eQg14946":{"id":"1rD5hutK5sLOBEaRzNLT","tag":"a"},"product-subscribe-50LpKJCiZTPNWgJ514945":{"id":"5A4zs9nn5eAUq4NsR70x","tag":"a"},"product-subscribe-tM9jf0BsgwsEG9hT14911":{"id":"hN9yFkEBUzYpC2nz7jgn","tag":"a"},"product-subscribe-7deI0GyTIbfVOcBS14895":{"id":"y8uTAVS65X0EBcvVr641","tag":"a"},"product-subscribe-fypkinhPWy81wlfa14894":{"id":"lMPYeNQzt2iW2ivOGnmB","tag":"a"},"product-subscribe-mXxG0vTN164c35jF14893":{"id":"Ep4UtICtRAlwcfh2Emtu","tag":"a"},"product-subscribe-S0oDv6N93Xk9bPdi14892":{"id":"7mWdOLHM4BkLq9gyKOaY","tag":"a"},"product-subscribe-05ZfIFm0Cnhl7Imb14891":{"id":"0Bci5ghDP3QlwJSf0KaV","tag":"a"},"product-subscribe-Gp3WyclRaYbn36dD14890":{"id":"f9D3tYyGHZoAu5NJXHdG","tag":"a"},"product-subscribe-KLVrzBEsYviELaSj14889":{"id":"0ZbBEfGBcumwHNp7ZLNO","tag":"a"},"product-subscribe-X02QnUbn3xudmZ1L14888":{"id":"hVou04c0KJRqKsOSbJdN","tag":"a"},"product-subscribe-yXla3oPVDYN3Vur214887":{"id":"PSDR4KT6JyIUbpzMRPno","tag":"a"},"product-subscribe-5jNhetoC9Bk1XyPS14846":{"id":"y7iTY5Ev4WtKdzQuxfrf","tag":"a"},"product-subscribe-jdyOsUDtLILYi3in14845":{"id":"dN9jQJxzoHBS3xbGgaHV","tag":"a"},"product-subscribe-gXry0Ckk4R3BT33I14844":{"id":"S2XMx6bmPsL8sFhZ2xSm","tag":"a"},"product-subscribe-GQLIe2jHz8qlm1wz14843":{"id":"yPv6y9kFCze7AablsZJB","tag":"a"},"product-subscribe-sOSj4GOn3b71eEYr14842":{"id":"7ykiDhZjNZnwRnj2ylL7","tag":"a"},"product-subscribe-jKRg5V6Pc8iFcEzQ14841":{"id":"WD98LMGnvF5u84SvsZys","tag":"a"},"product-subscribe-31PEcO75pIcROBQU14840":{"id":"R4ww7PhUfIWlAUwxsT7O","tag":"a"},"product-subscribe-HJyjOq2tikd2FSK614798":{"id":"aqBbbagDahKCsyrf5jGj","tag":"a"},"product-subscribe-218PhgawNrm1JELd14797":{"id":"OkjW50DWfvwrYu8gyald","tag":"a"},"product-subscribe-wzaEfWMwGxJoOY2u14796":{"id":"m5HbgsQ6Vz8z1kY4F1XD","tag":"a"},"product-subscribe-TUqdfeOJEl1kzzOT14795":{"id":"3kK0p9Enf6wjmm42ffLU","tag":"a"},"product-subscribe-NVVYbYS3DrjYDnbF14774":{"id":"G2umaj0vz2sKUzIOwPRh","tag":"a"},"product-subscribe-PomMwfXUqs2IOtIm14762":{"id":"uN6NNaD6b1U9sjNto7dN","tag":"a"},"product-subscribe-c5EPhrLOMTlZ7Tuv14761":{"id":"QeHeSZVtyNuu9zNRyzmu","tag":"a"},"product-subscribe-BG6RUC1AATxL2G6014725":{"id":"kzm8VCfne3XwJeaSXAmt","tag":"a"},"product-subscribe-0gaBCnnSQvwbkS9G14707":{"id":"ZinqyAtnd8T43iEaG929","tag":"a"},"product-subscribe-AVfjo8KFcEkACtTX14701":{"id":"CtqyeablMWYjAZz4MQpq","tag":"a"},"product-subscribe-1c5PbFKkfGWTys6614700":{"id":"mD69zoMCK433XBWBNio5","tag":"a"},"product-subscribe-qWn2qbh0IKfNpfsk14699":{"id":"xdHvh84rQO70o4yflUzA","tag":"a"},"product-subscribe-tFnnvaMXN4MyxZtW14698":{"id":"UGRUo17rWYSFwAfRrw3M","tag":"a"},"product-subscribe-BROlVfnoMtJk8W4j14697":{"id":"Zc8raAUZh0K0f7N4c8NW","tag":"a"},"product-subscribe-Mp7DAJ9pmRuD9yPF14696":{"id":"xedSCruQosmIA15bJj3M","tag":"a"},"product-subscribe-iN5lKARgJWKwEDPJ14695":{"id":"qjuiypEF50E8mLFFqhlK","tag":"a"},"product-subscribe-nMz8C6x9pQPAzt3y14694":{"id":"7bfRDQJYQQn9dPy4xDqa","tag":"a"},"product-subscribe-YmO2AddjHOkAaQbk14481":{"id":"eWoVovbjGifEq4xZOmut","tag":"a"},"product-subscribe-Hf03N2WnGVoO542X14479":{"id":"JWl7ZWMFcGdpQAp6JWPO","tag":"a"},"product-subscribe-W4zRXjcSq8S1Q26314393":{"id":"THVgQqBm81pt9yTuSdzr","tag":"a"},"product-subscribe-x4q89iHlGfzFaHDF14346":{"id":"Bs3GDYjKvPKIDX0EiSaQ","tag":"a"},"product-subscribe-2pauKbKqsWPgd6T814345":{"id":"xOkvQkc0xysanYfmOiVq","tag":"a"},"product-subscribe-YmW8kp91gpaTzrOS14318":{"id":"Bl6uZEgfzGTGEOSqNdTG","tag":"a"},"product-subscribe-oJJi3QSe1oKjIXyJ14288":{"id":"hLa5WGH6HX8viaInx4nA","tag":"a"},"product-subscribe-sILG315q7DgNmWJH14275":{"id":"0QjBeKzvv5U0cYgk2M0i","tag":"a"}},"errors":[],"htmlHash":"87fc3f9f","data":{"books":[],"perPage":6,"page":27,"category":[],"ids":[14]},"dataMeta":{"modelCollections":{"books":{"class":"App\\Models\\Book","id":["20401","19255","19253","18496","18245","18218","17621","17348","17074","17068","16469","16452","16451","16010","15963","15740","15511","15409","14799","12394","10180","10178","9259","8620","8041","7888","6800","6769","6733","6505","6492","6482","5598","5597","5596","5464","5390","5288","4399","4366","3802","3372","3369","3358","3347","3339","3338","3336","2596","2312","2270","2263","2257","2256","2246","1068","1011","733","709","163","20773","20758","20751","20738","20514","20309","18758","18564","16986","16828","15939","15829","15817","15784","15763","15746","15340","15140","15131","15113","15112","15111","15110","15109","15108","15103","15102","15101","15100","15075","15074","15073","15072","15060","15059","15057","15045","15043","15042","15041","15026","15025","15024","15023","15022","15021","15020","15019","15017","15016","15014","15012","15011","14954","14953","14951","14948","14947","14946","14945","14911","14895","14894","14893","14892","14891","14890","14889","14888","14887","14846","14845","14844","14843","14842","14841","14840","14798","14797","14796","14795","14774","14762","14761","14725","14707","14701","14700","14699","14698","14697","14696","14695","14694","14481","14479","14393","14346","14345","14318","14288","14275"],"relations":["series","publisher","authors","authors.media","discountOffer","media","subscribers"],"connection":"mysql"}},"models":{"category":{"class":"App\\Models\\Category","id":"سياسة","relations":["children"],"connection":"mysql"}}},"checksum":"a978b9f9cb184baf2016d28758b9f4efa7faf13cadc95f1a53d44903ac4ce7ca"},"updates":[{"type":"callMethod","payload":{"id":"2a5n","method":"loadMore","params":[]}}]}
headers = {
"content-type":"application/json",
"x-csrf-token": token,
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36",
"x-livewire": "true"
}
req = session.post('https://www.aseeralkotb.com/livewire/message/categories.books.index', json=data, headers=headers).json()
json_content = req['effects']['html']
soup = bs(json_content, "lxml")
#print(soup)
for card in soup.select('div[class="flex"]'):
name = card.select_one('div.flex.flex-col.items-center > a > h1').text
print(name)
Output:
سياسات تقنين الشريعة
بعد الليبرالية
الاعلان الاسلامي
في قلب الأحداث
الدولة والثورة
أحاديث فى آسيا
العالم عام 2050
حرب المائة عام على ف..
تاريخ العصامية والجر..
البرجوازية المصرية و..
الدبلوماسية الإقتصاد..
عدني يا أبي - عام من..
عولمة - لا حرب حضارا..
الإستياء العالمي - ح..
العبودية مقابل الامن..
أيام مرسي
11 يوما مات بعدها جم..
33 استراتيجية للحرب
المختطفات : شهادات م..
روسيا الأوراسية كقوة..
ملفات السويس
سنوات الغليان
اختلال العالم
الماسونية
خرافة التقدم والتأخر
نحن شعب مهذب - تأملا..
خوف
كل يوم هو اضافة
هرطقات 2: عن العلمان..
الحصار
الجورنالجي وكاتم الا..
أميركا والقوى الصاعد..
مقدمة قصيرة عن الحرب..
مقدمة قصيرة عن الثور..
مقدمة قصيرة عن الثور..
القاهرة - موسكو
قصة سقوط صدام حسين
فن الحرب
الحروب الميسرة
أسرار حرب الغاز
اليوتوبية: مقدمة قصي..
الحياة السرية لصدام..
موسوليني - أسطورة لا..
الأسرار الكبرى للماس..
أسرار وحقيقة الماسون..
أحجار على رقعة الشطر..
يأجوج ومأجوج- من الو..
الشيطان أمير هذا الع..
غزة في أزمة - تأملات..
كل جيش الكرملين ( مو..
أخيل جريحا ( إرث جم..
ماذا حدث للمصريين؟
العلمانية الجزئية وا..
العلمانية الجزئية وا..
عودة الوعى
موسوليني وهتلر : قصة..
الثورة الدائمة
نار وغضب - البيت الأ..
حلقات زحل
كفاحي
لعبة الأمم
آليات المؤامرة الكون..
استنساخ الفشل التار..
عمالقة الفن الاسود
الرقابة و التعتيم فى..
الاختراق الصهيونى لل..
جند الخلافة
محكمة حقوق الإنسان ا..
مذكرات هيرمان بلاك
الجيش الأمريكى فى حر..
روح الشرائع
خنجر إيران
المتآمرون على الأمة
الثورة العميقة رحلة..
جمهورية الضحك الأولي
عالم بدون اسرائيل
المقاصد الشرعية في ا..
الحروب الامريكية الج..
معجم المصطلحات السيا..
حقوق عربية ضائعة .....
من الشاه الى نجاد....
العلاقات المصرية الخ..
الحكومة الإلكترونية..
العمالة الأجنبية في..
الديموقراطية الخليجي..
الديمقراطية الكويتية..
مصطفى النحاس ودوره ف..
الأمم المتحدة والتدخ..
الاسلاموفبيا جماعات..
تاريخ أفغانستان وتطو..
الثورة التشيكية وتجر..
قوة المستضعفين
اشهر قضايا الاغتيالا..
المرأة والربيع العرب..
التجربة البرازيلية ق..
اسرائيل في حوض النيل
أوربيانا - مختصر تار..
يوميات دولة انتقالية
تجربة جنوب افريقيا -..
التجربة الماليزية -..
المياة العربية وحروب..
سياسة ايران تجاة دول..
التجربه التشيلية .....
التجربه الاندونسيه ...
التجارة الخارجيه الي..
الدور البرلمانى للمر..
محنه الدستور ... وإش..
الحروب بالوكالة - اد..
العلاقات السعوديه ال..
هاربون من الموت : ال..
كيفية صناعة التطرف ؟..
الفساد والإصلاح : ال..
العلاقات الأمريكية ا..
التجربة الصينية الما..
دينى ودين الناس .. ا..
الأرض المحرمة - كوري..
القضية الكردية : إشك..
العلاقات الإيرانية ا..
السياسة الخارجية الت..
العلاقات الإيرانية ا..
القومية والأمة: مدخل..
التجربة الالمانية ....
التجربة الإماراتية :..
بوكو حرام : من الجما..
التجربة الهندية : أك..
ماذا تعرف عن البركست..
العلاقات اليمنية الخ..
أمريكا وحركات الإسلا..
المشروع الصهيوني: ال..
وحدتنا الوطنية بين ث..
ليبيا ما بعد القذافي..
النظام الانتخابي ....
ضد الانتخابات .. دفا..
التجربة الكندية .. ب..
التجربة الإيرانية....
التجربة الأرجنتينية..
التجربة الباكستانية..
الثورة والحرب .. تشك..
الأقليات في أثيوبيا..
العلاقات السورية الت..
العلاقات الصينية الأ..
كتابات هيكل .. بين ا..
التعليم الالالكتروني..
البرنامج النووي الاي..
لماذا تنتفض الشعوب ؟..
العنف المقدس.. النفو..
قضايا الخيانة والجاس..
مدخل الي القرن الافر..
إخوان مصر .. بين الص..
أمريكا والربيع العرب..
العلاقات المصرية الا..
العلاقات بين الكوريت..
سد النهضة الإثيوبي ...
آخر أيام البشير .. ا..
التجربة.. تفاعلات ال..
عزيزي النفط.. ماذا ف..
ملوك النفط .. كيف قل..
الشغف العربي
المنافسة على القمة و..
اليمن والقاعدة.. الح..
في عين العاصفة
مصدق والصراع على الس..
مصدق والصراع على الس..
الفكر السياسي للأحزا..
الثورات العربية.. سي..
التمرد السوري
قيامة شعب .. قراءة أ..
في أصول لبنان الطائف..
Related
How can i get a warning pop up before saving
I'm on Odoo 14 and I wonder how can I get a warning message when some require fields are empty before saving. This is what I try to do : warning_message = { 'title': ('Attention!'), 'message': ('Certains champs requis sont vides, est tu sûr de vouloir sauvegarder?'), } #api.onsave def onsave_check_fields(self): for field in self.fields: if field.require == True: if field.value == empty: if warning_message: return save() return save()
For Web-forms on your website (front office): In your xml template (here : id="your_form_template_id") : <t t-if="error" t-foreach="error.get('error_message', [])" t-as="err"><h4 class="text-danger" t-esc="err" /></t> <form action="/process_form_inputs"> <input type="hidden" name="field_required" t-att-value="'phone,name'" /> <input type="hidden" name="submitted" value="1" /> <label for="name">Name</label><input type="text" name="name" value="" /> <label for="name">Email</label><input type="text" name="email" value="" /> <label for="name">Phone</label><input type="text" name="phone" value="" /> </form> For Web-forms on your website (front office), the right place to check form inputs is not in your odoo-model file: your_(inherited)model/models/your_model.py. But in your odoo-controller file : your_(inherited)model/controller/main.py #http.route(['/process_form_inputs'], type='http', methods=['GET', 'POST'], auth="public", website=True, sitemap=False) def process_form(self, **kw): # form input fields,values are sent in kw # IF POSTED if 'submitted' in kw: partner_fields = request.env['res.partner']._fields pre_values = { k: (bool(v) and int(v)) if k in partner_fields and partner_fields[k].type == 'many2one' else v for k, v in kw.items() } errors, error_msg = self.onsave_check_fields(kw, pre_values) if not errors: # YOUR CODE TO CREATE OR UPDATE THE MODEL-record : Partner.create(values) or Partner.browse(id).write(values) return request.redirect('/success_page') else: errors['error_message'] = error_msg values = kw render_values={'form_values': values,'error': errors,} return request.render("your_module.your_form_template_id", render_values) def onsave_check_fields(self, all_form_values, data): error = dict() error_message = [] # Required fields from form required_fields = [f for f in (all_form_values.get('field_required') or '').split(',') if f] # error message for empty required fields for field_name in required_fields: if not data.get(field_name): error[field_name] = 'missing' return error, error_message
Capture links in scrapy using regex as selector
<svg version="1.1" id="Calque_1" xmlns="&ns_svg;" xmlns:xlink="&ns_xlink;" width="700" height="700" viewBox="0 0 300 300" overflow="visible" enable-background="new 0 0 300 300" xml:space="preserve"> <a xlink:href="https://www.pros-locations-de-voitures.fr/location-de-voiture-ain-01/" onmouseover="TipFunction('Ain')" onmouseout="TipFunction('')"><path id="Z1" title="Ain" d="M237.125,152.725l-1.7-1l-2.4,3.3l-2.7,1.6l-2,0.1l-0.2-1.4l-1.6-0.8l-2,2.2l-1.5,0.1v-1.5h-1.5l-2.1-3.9 l-2.5-1.6l-2.7,0.6l-2.9-0.8l-2.9,10.5l-0.8,4l1.5,4.6l1.5-0.3l1.8,2.9l3.2-0.3l3,1l1.5-2.5l1.4-0.4l5.6,7.6l2.9-3.3l1.1-6.8 l-0.4-4.7h1.5l1.3-1.4h-0.1l0.3-2.6l2.8-1.7L237.125,152.725z" fill="red" stroke="#EEEEEE" stroke-width="0.9"></path> </a> <a xlink:href="https://www.pros-locations-de-voitures.fr/location-de-voiture-aisne-02/" onmouseover="TipFunction('Aisne')" onmouseout="TipFunction('')"><path id="Z2" title="Aisne" d="M179.025,42.325l-6.3,0.4l-0.2,1.8l-1.9,4.1l1.1,3.5l0.2,5.1l-0.3,2.2l1.1,0.9l-1.3,0.6l-1.2,2.8l-1.3,0.8 l1.4,2.3l-1.5-0.1l0.4,1.5l1.2-0.8l1.4,0.6l0.3,1.4l-1.1,0.8l1.3,0.4l0.9,1.2l-0.3,1.4l1.9,2.1l4.7,3l3.8-5.1l-1.3-0.6l0.5-1.4 l-0.8-1.2l2.7-1.1l-1.6-4l0.6-1.4l4-2l2.7,1l0.4-1.5l-0.1-7.1l1.4-0.1l2.5-3.6l-0.7-1.6l0.7-1.7l-0.4-2.9h-0.2l-1.8-0.6v-0.1 l-7.8-2.1l-2.6,0.9l-1.2-0.9L179.025,42.325z " fill="#094353" stroke="#EEEEEE" stroke-width="0.9"></path> </a> While testing the regex pattern its working fine and matches the links but while applying in code it returning empty list. import scrapy class scraper(scrapy.Spider): name = "scraper" start_urls = ["https://www.pros-locations-de-voitures.fr/"] def parse(self, response): yield { 'Links' : response.selector.re('(?<=xlink:href=").*?(?=")') }
The data you are looking for is loaded via javascript so to gain access to the data you will have to pre-render the page using either scrapy-splash, selenium or scrapy-playwright. You can then use below xpath selector to obtain the urls. No need to use regex in this case response.xpath("//*/#*[name()='xlink:href']").getall()
why scrapy can not find xpath that is found in my browser xpath?
Im a newby to scrapy and Im having dificulties extracting the price but not the name using the code below. Any idea what Im doing wrong to get the price? Thank you! This is the code: import scrapy class BfPreciosSpider(scrapy.Spider): name = 'BF_precios' allowed_domains = ['https://www.boerse-frankfurt.de'] start_urls = ['https://www.boerse-frankfurt.de/anleihe/xs1186131717-fce-bank-plc-1-134-15-22'] def parse(self, response): what_name=response.xpath('/html/body/app-root/app-wrapper/div/div[2]/app-bond/div[1]/div/app-widget-datasheet-header/div/div/div/div/div[1]/div/h1/text()').extract_first() what_price=response.xpath('/html/body/app-root/app-wrapper/div/div[2]/app-bond/div[2]/div[3]/div[1]/font/text()').extract_first() yield{'name': what_name , 'price': what_price} And these are the items(in red) - name and price:
The name information is available directly on the page but the price information is obtained from an api. If you investigate the Network traffic you will find an api call that returns the price information. See below example of how you could obtain this data. import scrapy from time import time class RealtorSpider(scrapy.Spider): name = 'BF_precios' allowed_domains = ['boerse-frankfurt.de'] custom_settings = { 'USER_AGENT': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.80 Safari/537.36' } start_urls = ['https://www.boerse-frankfurt.de/anleihe/xs1186131717-fce-bank-plc-1-134-15-22'] def parse(self, response): item = {} current_time = int(time()) name = response.xpath('//h1/text()').get() isin = response.xpath("//span[contains(text(),'ISIN:')]/text()").re_first(r"ISIN:\s(.*)$") mic = response.xpath("//app-widget-index-price-information/#mic").get() api_url = f"https://api.boerse-frankfurt.de/v1/tradingview/lightweight/history/single?\ resolution=D&isKeepResolutionForLatestWeeksIfPossible=false\ &from={current_time}&to={current_time}&isBidAskPrice=false&symbols={mic}%3A{isin}" item['name'] = name item['isin'] = isin item['mic'] = mic yield response.follow(api_url, callback=self.parse_price, cb_kwargs={"item": item}) def parse_price(self, response, item): item['price'] = response.json()[0]['quotes']['timeValuePairs'][0]['value'] yield item Running the above spider will yield a dictionary similar to the below {'name': 'FCE Bank PLC 1,134% 15/22', 'isin': 'XS1186131717', 'mic': 'XFRA', 'price': 99.955}
Django List from empty models got TypeError: unhashable type: 'list'
Sorry for my poor English, I'm working around several days and I'm blocked, I clean my develop/debug database and after that my code that just didn't work any more. I'm working for around to understand the reason and how to solve, but no clue. Ask for any path to go to solve this situation and help me. I know I'm doing something wrong because only did: ./manage.py --fork contractos zero clean all migrations data on contractos/migrations (except init.py) ./manage.py --fake ./manage.py makemigrations ./manage.py migrate ./manage.py runserver <code> my list.py from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.http import Http404 from django.shortcuts import render # Create your views here. from contractos.models import Contracto def list(request): if not request.user.is_staff and not request.user.is_superuser: raise Http404 contractos_list = Contracto.objects.all() #.order_by("empresa") paginator = Paginator(contractos_list, 10) # Show 25 contacts per page page_request_var = 'lista' page = request.GET.get(page_request_var) try: contractos = paginator.page(page) except PageNotAnInteger: #If page is not an integer, deliver first page. contractos = paginator.page(1) except EmptyPage: #If page is out of range (e.g. 9999), deliver last page of results. contractos = paginator.page(paginator.num_pages) context = { "object_list" : contractos, "title": "Lista de Contractos", "page_request_var": page_request_var, } return render(request, "contractos/list.html", context) **my list.html** {% extends "base.html" %} {% block content %} <div class="col-sm-9 col-sm-offset-1"> <h1>Contractos {{ title }}</h1> <div class="row"> {% for obj in object_list %} <div class="col-sm-6 col-md-4"> <div class="thumbnail"> <div class="caption"> <h3> <a href='{{ obj.get_absolute_url }}'>{{ obj.empresa }} </a><br /> {% if obj.logo %} <img src="{{ obj.logo.url }}" class="img-responsive"/> {% endif %} <small>criado {{ obj.timestamp|timesince }}</small><br /> <small>alterado em {{ obj.updated|timesince }}</small><br /> </h3> {{ obj.nfic }} <br/> {{ obj.descricao|linebreaks|truncatechars:60 }} <p>...</p> <p>Detalhes <!--a href="#" class="btn btn-default" role="button">Button</a--></p> </div> </div> </div> {% cycle "" "<div class='col-sm-12'><hr/></div></div><div class='row'>" %} {% endfor %} </div> <div class="pagination"> <span class="step-links"> {% if object_list.has_previous %} Primeira Anterior {% endif %} <span class="current"> {% if object_list.number %} Pagina {{ object_list.number }} de {{ object_list.paginator.num_pages }}. {% endif %} </span> {% if object_list.has_next %} Seguinte Ultima {% endif %} </span> </div> </div> {% endblock content %} **my models.py** from __future__ import unicode_literals import uuid from django.db import models from django.core.urlresolvers import reverse STATUS_CHOICES = [ ('a', 'Activo'), ('s', 'Suspenso'), ('c', 'Cancelado'), ('t', 'Terminado'), ] def upload_location(instance, filename): return "contractos/%s/%s" % (instance.nfic, filename) # Create your models here. class Contracto(models.Model): slug = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) nfic = models.CharField(max_length=15, default='PT000000000', unique=True) empresa = models.CharField(max_length=128, unique=True) descricao = models.TextField() status = models.CharField(max_length=1, choices=STATUS_CHOICES, default='a') logo = models.ImageField(upload_to=upload_location, null=True, blank=True, width_field="width_field", height_field="height_field" ) height_field = models.IntegerField(default=0) width_field = models.IntegerField(default=0) updated = models.DateTimeField(auto_now=True, auto_now_add=False) timestamp = models.DateTimeField(auto_now=False, auto_now_add=True) def __str__(self): return self.empresa def get_absolute_url(self): return reverse("contractos:details", kwargs={"uuid": self.slug}) class Meta: ordering = ["empresa"] db_table = ["Contractos"] and the error I got when try rendering list.py are: **Environment:** Request Method: GET Request URL: http://127.0.0.1:8000/contractos/ Django Version: 1.10.4 Python Version: 3.5.1 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'contractos'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware'] Traceback: File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/core/paginator.py" in validate_number 34. number = int(number) **During handling of the above exception (int() argument must be a string, a bytes-like object or a number, not 'NoneType'), another exception occurred:** File "/home/gwo/Projects/paas/src/contractos/views/list.py" in list 20. contractos = paginator.page(page) File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/core/paginator.py" in page 50. number = self.validate_number(number) File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/core/paginator.py" in validate_number 36. raise PageNotAnInteger('That page number is not an integer') **During handling of the above exception (That page number is not an integer), another exception occurred:** File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/core/paginator.py" in count 72. return self.object_list.count() File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/db/models/query.py" in count 369. return self.query.get_count(using=self.db) File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/db/models/sql/query.py" in get_count 476. number = obj.get_aggregation(using, ['__count'])['__count'] File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/db/models/sql/query.py" in get_aggregation 457. result = compiler.execute_sql(SINGLE) File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/db/models/sql/compiler.py" in execute_sql 824. sql, params = self.as_sql() File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/db/models/sql/compiler.py" in as_sql 369. extra_select, order_by, group_by = self.pre_sql_setup() File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/db/models/sql/compiler.py" in pre_sql_setup 46. self.setup_query() File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/db/models/sql/compiler.py" in setup_query 36. self.query.get_initial_alias() File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/db/models/sql/query.py" in get_initial_alias 879. alias = self.join(BaseTable(self.get_meta().db_table, None)) File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/db/models/sql/query.py" in join 921. alias, _ = self.table_alias(join.table_name, create=True) File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/db/models/sql/query.py" in table_alias 689. alias_list = self.table_map.get(table_name) **During handling of the above exception (unhashable type: 'list'), another exception occurred:** File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner 39. response = get_response(request) File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response 187. response = self.process_exception_by_middleware(e, request) File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response 185. response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/home/gwo/Projects/paas/src/contractos/views/list.py" in list 23. contractos = paginator.page(1) File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/core/paginator.py" in page 50. number = self.validate_number(number) File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/core/paginator.py" in validate_number 39. if number > self.num_pages: File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/utils/functional.py" in __get__ 35. res = instance.__dict__[self.name] = self.func(instance) File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/core/paginator.py" in num_pages 84. if self.count == 0 and not self.allow_empty_first_page: File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/utils/functional.py" in __get__ 35. res = instance.__dict__[self.name] = self.func(instance) File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/core/paginator.py" in count 77. return len(self.object_list) File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/db/models/query.py" in __len__ 238. self._fetch_all() File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/db/models/query.py" in _fetch_all 1087. self._result_cache = list(self.iterator()) File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/db/models/query.py" in __iter__ 54. results = compiler.execute_sql() File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/db/models/sql/compiler.py" in execute_sql 824. sql, params = self.as_sql() File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/db/models/sql/compiler.py" in as_sql 369. extra_select, order_by, group_by = self.pre_sql_setup() File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/db/models/sql/compiler.py" in pre_sql_setup 46. self.setup_query() File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/db/models/sql/compiler.py" in setup_query 36. self.query.get_initial_alias() File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/db/models/sql/query.py" in get_initial_alias 879. alias = self.join(BaseTable(self.get_meta().db_table, None)) File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/db/models/sql/query.py" in join 921. alias, _ = self.table_alias(join.table_name, create=True) File "/home/gwo/Projects/paas/lib/python3.5/site-packages/django/db/models/sql/query.py" in table_alias 689. alias_list = self.table_map.get(table_name) **Exception Type: TypeError at /contractos/ Exception Value: unhashable type: 'list'** </code> </pre> So I only clean my data from database to restart populate then again with test information to demonstrated the project to our customer, that as you can imagine I had to cancel!
You can't have a function called list because it's a python keyword. Change that to something else and it will work. Also you should avoid naming your file list etc.
How do I clear values from text_field_tag after browser refresh?
I'm having an issue with text_field_tag. I want to reset the value of the text_field when I refresh my browser, seems like a very simple thing, however I'm having hard time finding the answer. After I input some values, how do i reset the value to nil or empty?? my code is below <%= text_field_tag 'access_code', nil, %> Any help or tip will be greatly appreciated. This is my session new page and access_code which I enter in text field is define in config.yml file. If I don't enter any access code in text field still I get the value in my controller which I enter last time...how can I reset the value?...... Thanks in advance! logs- : Started POST "/login" for 127.0.0.1 at 2015-06-09 16:14:26 +0530 I, [2015-06-09T16:14:26.368484 #6707] INFO -- : Processing by SessionsController#new as HTML I, [2015-06-09T16:14:26.368731 #6707] INFO -- : Parameters: {"utf8"=>"✓", "authenticity_token"=>"Dw7fO0ZyO4/ZPnNknuXbt4xsLkGWlxM3rmaEYvClTDRjq0dLdVUGt84Pw2ZNBQ8Sz2x7BGZwlHCmq3EozDmoJg==", "access_code"=>"12345", "login"=>"admin", "password"=>"[FILTERED]", "commit"=>"Log in"} D, [2015-06-09T16:14:26.372837 #6707] DEBUG -- : [1m[36mActiveRecord::SessionStore::Session Load (0.7ms)[0m [1mSELECT `sessions`.* FROM `sessions` WHERE `sessions`.`session_id` = '261e811b132a8cf574d6733a2bf5a2f4' ORDER BY `sessions`.`id` ASC LIMIT 1[0m I, [2015-06-09T16:14:26.376843 #6707] INFO -- : checking for Mobile Device - Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.81 Safari/537.1 D, [2015-06-09T16:14:39.505665 #6707] DEBUG -- : [1m[35mSQL (1.1ms)[0m SELECT `users`.`id` AS t0_r0, `users`.`login` AS t0_r1, `users`.`email` AS t0_r2, `users`.`encrypted_password` AS t0_r3, `users`.`password_salt` AS t0_r4, `users`.`created_at` AS t0_r5, `users`.`updated_at` AS t0_r6, `users`.`remember_token` AS t0_r7, `users`.`remember_token_expires_at` AS t0_r8, `users`.`reset_password_token` AS t0_r9, `users`.`enabled` AS t0_r10, `users`.`customer_id` AS t0_r11, `users`.`status` AS t0_r12, `users`.`plain_password` AS t0_r13, `users`.`last_checked_at` AS t0_r14, `users`.`sign_in_count` AS t0_r15, `users`.`current_sign_in_at` AS t0_r16, `users`.`last_sign_in_at` AS t0_r17, `users`.`current_sign_in_ip` AS t0_r18, `users`.`last_sign_in_ip` AS t0_r19, `users`.`created_by` AS t0_r20, `users`.`failed_attempts` AS t0_r21, `users`.`disable_reason` AS t0_r22, `customers`.`id` AS t1_r0, `customers`.`name` AS t1_r1, `customers`.`customer_type` AS t1_r2, `customers`.`parent_id` AS t1_r3, `customers`.`created_at` AS t1_r4, `customers`.`updated_at` AS t1_r5, `customers`.`meta_data` AS t1_r6, `customers`.`opt_out` AS t1_r7, `customers`.`fulfilled` AS t1_r8, `customers`.`complete` AS t1_r9, `customers`.`fulfillment_issue` AS t1_r10, `customers`.`deleted_at` AS t1_r11, `customers`.`generic_bulletin` AS t1_r12, `customers`.`archived` AS t1_r13, `customers`.`vendor_rep` AS t1_r14, `customers`.`vendor_rep_email` AS t1_r15, `customers`.`vendor_rep_phone_no` AS t1_r16, `customers`.`converted_to_new_year` AS t1_r17, `customers`.`fulfillment_info` AS t1_r18, `customers`.`slug` AS t1_r19, `customers`.`start_date` AS t1_r20, `customers`.`end_date` AS t1_r21, `customers`.`bcc_on_confirmation` AS t1_r22, `customers`.`sales_tax_type` AS t1_r23, `customers`.`sales_tax_rate` AS t1_r24, `customers`.`delta` AS t1_r25, `customers`.`time_zone` AS t1_r26, `customers`.`commission_perc_req_items` AS t1_r27, `customers`.`commission_perc_optional_items` AS t1_r28, `customers`.`commission_perc_spirit_items` AS t1_r29, `customers`.`commission_perc_blended_rate` AS t1_r30, `customers`.`credit_card_processing_rate` AS t1_r31, `customers`.`monthly_service_fee` AS t1_r32, `customers`.`annual_service_fee` AS t1_r33, `customers`.`store_building_fee` AS t1_r34, `customers`.`account_setup_fee` AS t1_r35, `customers`.`fee_calculated_pre_tax` AS t1_r36, `customers`.`fee_calculated_post_tax` AS t1_r37, `customers`.`handling_fee` AS t1_r38, `customers`.`advertisement` AS t1_r39, `customers`.`payment_receiver_override` AS t1_r40, `customers`.`banner_image` AS t1_r41, `customers`.`default_payment_receiver` AS t1_r42, `customers`.`handling_fee_type` AS t1_r43, `customers`.`support_email_address` AS t1_r44, `customers`.`discount_per_order` AS t1_r45, `customers`.`discount_per_order_min_amount` AS t1_r46, `customers`.`player_number_required` AS t1_r47, `customers`.`discount_text` AS t1_r48, `customers`.`discount_max_counts` AS t1_r49, `customers`.`discount_coupon_code` AS t1_r50, `customers`.`accept_check` AS t1_r51, `customers`.`accept_credit_card` AS t1_r52, `customers`.`store_shipping_rates` AS t1_r53, `customers`.`mobile_version_enabled` AS t1_r54, `customers`.`reminder_email` AS t1_r55, `customers`.`returning_player` AS t1_r56, `customers`.`edit_order_after_closed` AS t1_r57, `customers`.`custom_text_for_receipt` AS t1_r58, `customers`.`eligibility_check_for_free_items` AS t1_r59, `customers`.`eligible_for_free_items` AS t1_r60, `customers`.`storefront_intro` AS t1_r61, `customers`.`pickup_locations` AS t1_r62, `customers`.`enable_facebook` AS t1_r63, `customers`.`allow_customer_notes_storefront` AS t1_r64, `customers`.`accept_cash` AS t1_r65, `customers`.`fb_page_id` AS t1_r66, `customers`.`league_enabled` AS t1_r67, `customers`.`status` AS t1_r68, `customers`.`agree_store_terms` AS t1_r69, `customers`.`launch_store` AS t1_r70, `customers`.`allow_shipping` AS t1_r71, `customers`.`amex_payment_method` AS t1_r72, `customers`.`copied_start_fresh_from` AS t1_r73, `customers`.`custom_message` AS t1_r74 FROM `users` LEFT OUTER JOIN `customers` ON `customers`.`id` = `users`.`customer_id` WHERE `users`.`login` = 'admin' AND `customers`.`deleted_at` IS NULL ORDER BY `users`.`id` ASC LIMIT 1 I, [2015-06-09T16:14:39.511565 #6707] INFO -- : Authentication:: Failed Login for User ID 1 Failed Login Attempts set to 2 D, [2015-06-09T16:14:39.512570 #6707] DEBUG -- : [1m[36m (0.3ms)[0m [1mBEGIN[0m D, [2015-06-09T16:14:39.527978 #6707] DEBUG -- : [1m[35mUser Exists (0.9ms)[0m SELECT 1 AS one FROM `users` WHERE (`users`.`login` = 'admin' AND `users`.`id` != 1) LIMIT 1 D, [2015-06-09T16:14:39.534245 #6707] DEBUG -- : [1m[36mSQL (0.6ms)[0m [1mUPDATE `users` SET `failed_attempts` = 2, `updated_at` = '2015-06-09 10:44:39.514661' WHERE `users`.`id` = 1[0m D, [2015-06-09T16:14:39.611739 #6707] DEBUG -- : [1m[35m (73.7ms)[0m COMMIT I, [2015-06-09T16:14:39.623991 #6707] INFO -- : Rendered sessions/new.html.erb within layouts/application (5.1ms) I, [2015-06-09T16:14:42.294270 #6707] INFO -- : Completed 200 OK in 15925ms (Views: 2680.0ms | ActiveRecord: 77.4ms) D, [2015-06-09T16:14:42.295683 #6707] DEBUG -- : [1m[36m (0.3ms)[0m [1mBEGIN[0m D, [2015-06-09T16:14:42.302890 #6707] DEBUG -- : [1m[35mSQL (0.5ms)[0m UPDATE `sessions` SET `data` = 'BAh7CUkiEmRvbWFpbl92ZW5kb3IGOgZFRkkiB25hBjsAVEkiEF9jc3JmX3Rv\na2VuBjsARkkiMWJLV1ljRE1uUFRnWE1iQUMwK0RVcFVNQVZVWHc1NGRIQ00z\nMVNqeWM1Qkk9BjsARkkiEnBhc3NfYXR0ZW1wdHMGOwBGaQdJIgpmbGFzaAY7\nAFR7B0kiDGRpc2NhcmQGOwBUWwZJIgplcnJvcgY7AEZJIgxmbGFzaGVzBjsA\nVHsGSSIKZXJyb3IGOwBGSUM6HkFjdGl2ZVN1cHBvcnQ6OlNhZmVCdWZmZXIi\nAaFZb3VyIHVzZXJuYW1lIG9yIHBhc3N3b3JkIGlzIGluY29ycmVjdC4gPGJy\nLz5QbGVhc2UgdHJ5IGFnYWluIG9yIGNsaWNrIHRoZSBmb2xsb3dpbmcgbGlu\nayB0byByZXNldCB5b3VyIHBhc3N3b3JkOiA8YSBocmVmPScvZm9yZ290X3Bh\nc3N3b3JkJz5Gb3Jnb3QgUGFzc3dvcmQ8L2E+Lgc7AFQ6D0BodG1sX3NhZmVU\n', `updated_at` = '2015-06-09 10:44:42.298136' WHERE `sessions`.`id` = 45 D, [2015-06-09T16:14:42.363066 #6707] DEBUG -- : [1m[36m (58.4ms)[0m [1mCOMMIT[0m
its its a js request,then you need to explicitly use jquery to make all text fields html as empty as you are using javascript to submit a form and NOT html which would have caused a total page refresh by using redirect_to: new_session_url.So in your login method,you must use something like:- def login ##save the user info respond_to do |format| format.js end end login.js.erb $("#login-textbox").val(" "); OR, YOU CAN ADD PAGE SPECIFIC JAVASCRIPT TO CLEAR TEXTBOXES ONSUBMIT //add this js in your page $(document).ready(function() { $('#btnSubmit').click(function(e) { var isValid = true; $('input[type="text"]').each(function() { if ($.trim($(this).val()) == '') { isValid = false; $(this).css({ "border": "1px solid red", "background": "#FFCECE" }); } else { $(this).css({ "border": "", "background": "" }); } }); if (isValid == false) e.preventDefault(); else alert('Thank you for submitting'); }); });