我已从此javascript字符串中提取了所有product_id
"is_in_stock":false
我的下一步是使用
过滤掉缺货的尺码"custom_status":"Out of Stock"
或
sizes_in_stock = []
for size in all_product_ids:
if "Out of Stock" not in size["custom_status"]:
size_id = size["product_id"]
sizes_in_stock.append(size_id.split("_")[1])
我已经尝试过这个知道我不是正确的道路因为我使用这个为html -
product_url = "randomsite.com"
response1 = requests.get(product_url, headers=headers)
all_product_ids = re.findall('product_id":"([^"]+)', response1.text)
print(all_product_ids)
我需要做些什么来过滤掉缺货产品ID并将库存中的产品ID附加到我的列表中?
下面是我的代码,用于从javascript字符串和javascript字符串本身中提取产品ID @@@@@@@@@@@@@@@@@@@@@@@
代码提取“产品ID” -
{"is_in_stock":true,"custom_status_icon":"","custom_status":"","product_id":"93132"},"255":{"is_in_stock":true,"custom_status_icon":"","custom_status":"","product_id":"93133"},"256":{"is_in_stock":true,"custom_status_icon":"","custom_status":"","product_id":"93134"},"365":{"is_in_stock":true,"custom_status_icon":"","custom_status":"","product_id":"93135"},"257":{"is_in_stock":false,"custom_status_icon":"","custom_status":"Out of Stock","product_id":"93136","stockalert":""},"258":{"is_in_stock":false,"custom_status_icon":"","custom_status":"Out of Stock","product_id":"93137","stockalert":""},"364":{"is_in_stock":false,"custom_status_icon":"","custom_status":"Out of Stock","product_id":"93138","stockalert":""},"242":{"is_in_stock":false,"custom_status_icon":"","custom_status":"Out of Stock","product_id":"93139","stockalert":""},"246":{"is_in_stock":false,"custom_status_icon":"","custom_status":"Out of Stock","product_id":"93140","stockalert":""},"363":{"is_in_stock":false,"custom_status_icon":"","custom_status":"Out of Stock","product_id":"93141","stockalert":""},"248":{"is_in_stock":false,"custom_status_icon":"","custom_status":"Out of Stock","product_id":"93142","stockalert":""},"243":{"is_in_stock":false,"custom_status_icon":"","custom_status":"Out of Stock","product_id":"93143","stockalert":""},"368":{"is_in_stock":false,"custom_status_icon":"","custom_status":"Out of Stock","product_id":"93144","stockalert":""},"244":{"is_in_stock":false,"custom_status_icon":"","custom_status":"Out of Stock","product_id":"93145","stockalert":""},"247":{"is_in_stock":false,"custom_status_icon":"","custom_status":"Out of Stock","product_id":"93146","stockalert":""},"79":{"is_in_stock":false,"custom_status_icon":"","custom_status":"Out of Stock","product_id":"93147","stockalert":""}});
HTML javascript string -
<div class="product-options" id="product-options-wrapper">
<script type="text/javascript">
try {
var changeConfigurableStatus = true;
var stStatus = new StockStatus({"255":{"is_in_stock":false,"custom_status_icon":"","custom_status":"Out of Stock","product_id":"93004","stockalert":"\r\n<div class=\"alert-stock productmail-block\">\r\n\t<label>\r\n\t\tNotify me, when the product is back in stock\t<\/label>\r\n\t<input type=\"text\"\r\n\t\t name=\"guest_email\"\r\n\t\t id=\"productmail_guest_email-93004\"\r\n\t\t onKeyPress=\"return checkIt(event, 'https:\/\/www.thegoodwillout.com\/productmail\/email\/stock\/', $('button-email-send-93004'))\"\r\n\t\t class=\"input-text\"\r\n\t\t placeholder=\"Your email address\u2026\"\r\n\t\t size=\"30\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"product_id\"\r\n\t\t value=\"93004\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"type\"\r\n\t\t value=\"email\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"parent_id\"\r\n\t\t value=\"92805\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"uenc\"\r\n\t\t value=\"aHR0cHM6Ly93d3cudGhlZ29vZHdpbGxvdXQuY29tL2FkaWRhcy1jb25zb3J0aXVtLXNuZWFrZXItZXhjaGFuZ2UteC1hbGlmZS14LXN0YXJjb3ctc3Rhbi1zbWl0aC13aGl0ZS1jbTgwMDA,\" \/>\r\n\t<button type=\"button\"\r\n\t\t\tid=\"button-email-send-93004\"\r\n\t\t\tclass=\"strong button btn-cart amcart-ignore\"\r\n\t\t\tonclick=\"send_alert_email('https:\/\/www.thegoodwillout.com\/productmail\/email\/stock\/', this)\"\r\n\t\t\ttitle=\"Submit\">\r\n\t\t<span>Submit<\/span>\r\n\t<\/button>\r\n<\/div>\r\n"},"256":{"is_in_stock":true,"custom_status_icon":"","custom_status":"","product_id":"93005"},"365":{"is_in_stock":true,"custom_status_icon":"","custom_status":"","product_id":"93006"},"257":{"is_in_stock":true,"custom_status_icon":"","custom_status":"","product_id":"93007"},"258":{"is_in_stock":true,"custom_status_icon":"","custom_status":"","product_id":"93008"},"364":{"is_in_stock":true,"custom_status_icon":"","custom_status":"","product_id":"93009"},"242":{"is_in_stock":false,"custom_status_icon":"","custom_status":"Out of Stock","product_id":"93010","stockalert":"\r\n<div class=\"alert-stock productmail-block\">\r\n\t<label>\r\n\t\tNotify me, when the product is back in stock\t<\/label>\r\n\t<input type=\"text\"\r\n\t\t name=\"guest_email\"\r\n\t\t id=\"productmail_guest_email-93010\"\r\n\t\t onKeyPress=\"return checkIt(event, 'https:\/\/www.thegoodwillout.com\/productmail\/email\/stock\/', $('button-email-send-93010'))\"\r\n\t\t class=\"input-text\"\r\n\t\t placeholder=\"Your email address\u2026\"\r\n\t\t size=\"30\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"product_id\"\r\n\t\t value=\"93010\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"type\"\r\n\t\t value=\"email\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"parent_id\"\r\n\t\t value=\"92805\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"uenc\"\r\n\t\t value=\"aHR0cHM6Ly93d3cudGhlZ29vZHdpbGxvdXQuY29tL2FkaWRhcy1jb25zb3J0aXVtLXNuZWFrZXItZXhjaGFuZ2UteC1hbGlmZS14LXN0YXJjb3ctc3Rhbi1zbWl0aC13aGl0ZS1jbTgwMDA,\" \/>\r\n\t<button type=\"button\"\r\n\t\t\tid=\"button-email-send-93010\"\r\n\t\t\tclass=\"strong button btn-cart amcart-ignore\"\r\n\t\t\tonclick=\"send_alert_email('https:\/\/www.thegoodwillout.com\/productmail\/email\/stock\/', this)\"\r\n\t\t\ttitle=\"Submit\">\r\n\t\t<span>Submit<\/span>\r\n\t<\/button>\r\n<\/div>\r\n"},"246":{"is_in_stock":false,"custom_status_icon":"","custom_status":"Out of Stock","product_id":"93011","stockalert":"\r\n<div class=\"alert-stock productmail-block\">\r\n\t<label>\r\n\t\tNotify me, when the product is back in stock\t<\/label>\r\n\t<input type=\"text\"\r\n\t\t name=\"guest_email\"\r\n\t\t id=\"productmail_guest_email-93011\"\r\n\t\t onKeyPress=\"return checkIt(event, 'https:\/\/www.thegoodwillout.com\/productmail\/email\/stock\/', $('button-email-send-93011'))\"\r\n\t\t class=\"input-text\"\r\n\t\t placeholder=\"Your email address\u2026\"\r\n\t\t size=\"30\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"product_id\"\r\n\t\t value=\"93011\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"type\"\r\n\t\t value=\"email\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"parent_id\"\r\n\t\t value=\"92805\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"uenc\"\r\n\t\t value=\"aHR0cHM6Ly93d3cudGhlZ29vZHdpbGxvdXQuY29tL2FkaWRhcy1jb25zb3J0aXVtLXNuZWFrZXItZXhjaGFuZ2UteC1hbGlmZS14LXN0YXJjb3ctc3Rhbi1zbWl0aC13aGl0ZS1jbTgwMDA,\" \/>\r\n\t<button type=\"button\"\r\n\t\t\tid=\"button-email-send-93011\"\r\n\t\t\tclass=\"strong button btn-cart amcart-ignore\"\r\n\t\t\tonclick=\"send_alert_email('https:\/\/www.thegoodwillout.com\/productmail\/email\/stock\/', this)\"\r\n\t\t\ttitle=\"Submit\">\r\n\t\t<span>Submit<\/span>\r\n\t<\/button>\r\n<\/div>\r\n"},"363":{"is_in_stock":false,"custom_status_icon":"","custom_status":"Out of Stock","product_id":"93012","stockalert":"\r\n<div class=\"alert-stock productmail-block\">\r\n\t<label>\r\n\t\tNotify me, when the product is back in stock\t<\/label>\r\n\t<input type=\"text\"\r\n\t\t name=\"guest_email\"\r\n\t\t id=\"productmail_guest_email-93012\"\r\n\t\t onKeyPress=\"return checkIt(event, 'https:\/\/www.thegoodwillout.com\/productmail\/email\/stock\/', $('button-email-send-93012'))\"\r\n\t\t class=\"input-text\"\r\n\t\t placeholder=\"Your email address\u2026\"\r\n\t\t size=\"30\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"product_id\"\r\n\t\t value=\"93012\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"type\"\r\n\t\t value=\"email\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"parent_id\"\r\n\t\t value=\"92805\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"uenc\"\r\n\t\t value=\"aHR0cHM6Ly93d3cudGhlZ29vZHdpbGxvdXQuY29tL2FkaWRhcy1jb25zb3J0aXVtLXNuZWFrZXItZXhjaGFuZ2UteC1hbGlmZS14LXN0YXJjb3ctc3Rhbi1zbWl0aC13aGl0ZS1jbTgwMDA,\" \/>\r\n\t<button type=\"button\"\r\n\t\t\tid=\"button-email-send-93012\"\r\n\t\t\tclass=\"strong button btn-cart amcart-ignore\"\r\n\t\t\tonclick=\"send_alert_email('https:\/\/www.thegoodwillout.com\/productmail\/email\/stock\/', this)\"\r\n\t\t\ttitle=\"Submit\">\r\n\t\t<span>Submit<\/span>\r\n\t<\/button>\r\n<\/div>\r\n"},"248":{"is_in_stock":false,"custom_status_icon":"","custom_status":"Out of Stock","product_id":"93013","stockalert":"\r\n<div class=\"alert-stock productmail-block\">\r\n\t<label>\r\n\t\tNotify me, when the product is back in stock\t<\/label>\r\n\t<input type=\"text\"\r\n\t\t name=\"guest_email\"\r\n\t\t id=\"productmail_guest_email-93013\"\r\n\t\t onKeyPress=\"return checkIt(event, 'https:\/\/www.thegoodwillout.com\/productmail\/email\/stock\/', $('button-email-send-93013'))\"\r\n\t\t class=\"input-text\"\r\n\t\t placeholder=\"Your email address\u2026\"\r\n\t\t size=\"30\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"product_id\"\r\n\t\t value=\"93013\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"type\"\r\n\t\t value=\"email\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"parent_id\"\r\n\t\t value=\"92805\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"uenc\"\r\n\t\t value=\"aHR0cHM6Ly93d3cudGhlZ29vZHdpbGxvdXQuY29tL2FkaWRhcy1jb25zb3J0aXVtLXNuZWFrZXItZXhjaGFuZ2UteC1hbGlmZS14LXN0YXJjb3ctc3Rhbi1zbWl0aC13aGl0ZS1jbTgwMDA,\" \/>\r\n\t<button type=\"button\"\r\n\t\t\tid=\"button-email-send-93013\"\r\n\t\t\tclass=\"strong button btn-cart amcart-ignore\"\r\n\t\t\tonclick=\"send_alert_email('https:\/\/www.thegoodwillout.com\/productmail\/email\/stock\/', this)\"\r\n\t\t\ttitle=\"Submit\">\r\n\t\t<span>Submit<\/span>\r\n\t<\/button>\r\n<\/div>\r\n"},"243":{"is_in_stock":false,"custom_status_icon":"","custom_status":"Out of Stock","product_id":"93014","stockalert":"\r\n<div class=\"alert-stock productmail-block\">\r\n\t<label>\r\n\t\tNotify me, when the product is back in stock\t<\/label>\r\n\t<input type=\"text\"\r\n\t\t name=\"guest_email\"\r\n\t\t id=\"productmail_guest_email-93014\"\r\n\t\t onKeyPress=\"return checkIt(event, 'https:\/\/www.thegoodwillout.com\/productmail\/email\/stock\/', $('button-email-send-93014'))\"\r\n\t\t class=\"input-text\"\r\n\t\t placeholder=\"Your email address\u2026\"\r\n\t\t size=\"30\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"product_id\"\r\n\t\t value=\"93014\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"type\"\r\n\t\t value=\"email\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"parent_id\"\r\n\t\t value=\"92805\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"uenc\"\r\n\t\t value=\"aHR0cHM6Ly93d3cudGhlZ29vZHdpbGxvdXQuY29tL2FkaWRhcy1jb25zb3J0aXVtLXNuZWFrZXItZXhjaGFuZ2UteC1hbGlmZS14LXN0YXJjb3ctc3Rhbi1zbWl0aC13aGl0ZS1jbTgwMDA,\" \/>\r\n\t<button type=\"button\"\r\n\t\t\tid=\"button-email-send-93014\"\r\n\t\t\tclass=\"strong button btn-cart amcart-ignore\"\r\n\t\t\tonclick=\"send_alert_email('https:\/\/www.thegoodwillout.com\/productmail\/email\/stock\/', this)\"\r\n\t\t\ttitle=\"Submit\">\r\n\t\t<span>Submit<\/span>\r\n\t<\/button>\r\n<\/div>\r\n"},"368":{"is_in_stock":false,"custom_status_icon":"","custom_status":"Out of Stock","product_id":"93015","stockalert":"\r\n<div class=\"alert-stock productmail-block\">\r\n\t<label>\r\n\t\tNotify me, when the product is back in stock\t<\/label>\r\n\t<input type=\"text\"\r\n\t\t name=\"guest_email\"\r\n\t\t id=\"productmail_guest_email-93015\"\r\n\t\t onKeyPress=\"return checkIt(event, 'https:\/\/www.thegoodwillout.com\/productmail\/email\/stock\/', $('button-email-send-93015'))\"\r\n\t\t class=\"input-text\"\r\n\t\t placeholder=\"Your email address\u2026\"\r\n\t\t size=\"30\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"product_id\"\r\n\t\t value=\"93015\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"type\"\r\n\t\t value=\"email\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"parent_id\"\r\n\t\t value=\"92805\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"uenc\"\r\n\t\t value=\"aHR0cHM6Ly93d3cudGhlZ29vZHdpbGxvdXQuY29tL2FkaWRhcy1jb25zb3J0aXVtLXNuZWFrZXItZXhjaGFuZ2UteC1hbGlmZS14LXN0YXJjb3ctc3Rhbi1zbWl0aC13aGl0ZS1jbTgwMDA,\" \/>\r\n\t<button type=\"button\"\r\n\t\t\tid=\"button-email-send-93015\"\r\n\t\t\tclass=\"strong button btn-cart amcart-ignore\"\r\n\t\t\tonclick=\"send_alert_email('https:\/\/www.thegoodwillout.com\/productmail\/email\/stock\/', this)\"\r\n\t\t\ttitle=\"Submit\">\r\n\t\t<span>Submit<\/span>\r\n\t<\/button>\r\n<\/div>\r\n"},"244":{"is_in_stock":false,"custom_status_icon":"","custom_status":"Out of Stock","product_id":"93016","stockalert":"\r\n<div class=\"alert-stock productmail-block\">\r\n\t<label>\r\n\t\tNotify me, when the product is back in stock\t<\/label>\r\n\t<input type=\"text\"\r\n\t\t name=\"guest_email\"\r\n\t\t id=\"productmail_guest_email-93016\"\r\n\t\t onKeyPress=\"return checkIt(event, 'https:\/\/www.thegoodwillout.com\/productmail\/email\/stock\/', $('button-email-send-93016'))\"\r\n\t\t class=\"input-text\"\r\n\t\t placeholder=\"Your email address\u2026\"\r\n\t\t size=\"30\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"product_id\"\r\n\t\t value=\"93016\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"type\"\r\n\t\t value=\"email\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"parent_id\"\r\n\t\t value=\"92805\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"uenc\"\r\n\t\t value=\"aHR0cHM6Ly93d3cudGhlZ29vZHdpbGxvdXQuY29tL2FkaWRhcy1jb25zb3J0aXVtLXNuZWFrZXItZXhjaGFuZ2UteC1hbGlmZS14LXN0YXJjb3ctc3Rhbi1zbWl0aC13aGl0ZS1jbTgwMDA,\" \/>\r\n\t<button type=\"button\"\r\n\t\t\tid=\"button-email-send-93016\"\r\n\t\t\tclass=\"strong button btn-cart amcart-ignore\"\r\n\t\t\tonclick=\"send_alert_email('https:\/\/www.thegoodwillout.com\/productmail\/email\/stock\/', this)\"\r\n\t\t\ttitle=\"Submit\">\r\n\t\t<span>Submit<\/span>\r\n\t<\/button>\r\n<\/div>\r\n"},"247":{"is_in_stock":false,"custom_status_icon":"","custom_status":"Out of Stock","product_id":"93017","stockalert":"\r\n<div class=\"alert-stock productmail-block\">\r\n\t<label>\r\n\t\tNotify me, when the product is back in stock\t<\/label>\r\n\t<input type=\"text\"\r\n\t\t name=\"guest_email\"\r\n\t\t id=\"productmail_guest_email-93017\"\r\n\t\t onKeyPress=\"return checkIt(event, 'https:\/\/www.thegoodwillout.com\/productmail\/email\/stock\/', $('button-email-send-93017'))\"\r\n\t\t class=\"input-text\"\r\n\t\t placeholder=\"Your email address\u2026\"\r\n\t\t size=\"30\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"product_id\"\r\n\t\t value=\"93017\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"type\"\r\n\t\t value=\"email\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"parent_id\"\r\n\t\t value=\"92805\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"uenc\"\r\n\t\t value=\"aHR0cHM6Ly93d3cudGhlZ29vZHdpbGxvdXQuY29tL2FkaWRhcy1jb25zb3J0aXVtLXNuZWFrZXItZXhjaGFuZ2UteC1hbGlmZS14LXN0YXJjb3ctc3Rhbi1zbWl0aC13aGl0ZS1jbTgwMDA,\" \/>\r\n\t<button type=\"button\"\r\n\t\t\tid=\"button-email-send-93017\"\r\n\t\t\tclass=\"strong button btn-cart amcart-ignore\"\r\n\t\t\tonclick=\"send_alert_email('https:\/\/www.thegoodwillout.com\/productmail\/email\/stock\/', this)\"\r\n\t\t\ttitle=\"Submit\">\r\n\t\t<span>Submit<\/span>\r\n\t<\/button>\r\n<\/div>\r\n"},"79":{"is_in_stock":false,"custom_status_icon":"","custom_status":"Out of Stock","product_id":"93018","stockalert":"\r\n<div class=\"alert-stock productmail-block\">\r\n\t<label>\r\n\t\tNotify me, when the product is back in stock\t<\/label>\r\n\t<input type=\"text\"\r\n\t\t name=\"guest_email\"\r\n\t\t id=\"productmail_guest_email-93018\"\r\n\t\t onKeyPress=\"return checkIt(event, 'https:\/\/www.thegoodwillout.com\/productmail\/email\/stock\/', $('button-email-send-93018'))\"\r\n\t\t class=\"input-text\"\r\n\t\t placeholder=\"Your email address\u2026\"\r\n\t\t size=\"30\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"product_id\"\r\n\t\t value=\"93018\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"type\"\r\n\t\t value=\"email\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"parent_id\"\r\n\t\t value=\"92805\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"uenc\"\r\n\t\t value=\"aHR0cHM6Ly93d3cudGhlZ29vZHdpbGxvdXQuY29tL2FkaWRhcy1jb25zb3J0aXVtLXNuZWFrZXItZXhjaGFuZ2UteC1hbGlmZS14LXN0YXJjb3ctc3Rhbi1zbWl0aC13aGl0ZS1jbTgwMDA,\" \/>\r\n\t<button type=\"button\"\r\n\t\t\tid=\"button-email-send-93018\"\r\n\t\t\tclass=\"strong button btn-cart amcart-ignore\"\r\n\t\t\tonclick=\"send_alert_email('https:\/\/www.thegoodwillout.com\/productmail\/email\/stock\/', this)\"\r\n\t\t\ttitle=\"Submit\">\r\n\t\t<span>Submit<\/span>\r\n\t<\/button>\r\n<\/div>\r\n"},"249":{"is_in_stock":false,"custom_status_icon":"","custom_status":"Out of Stock","product_id":"93019","stockalert":"\r\n<div class=\"alert-stock productmail-block\">\r\n\t<label>\r\n\t\tNotify me, when the product is back in stock\t<\/label>\r\n\t<input type=\"text\"\r\n\t\t name=\"guest_email\"\r\n\t\t id=\"productmail_guest_email-93019\"\r\n\t\t onKeyPress=\"return checkIt(event, 'https:\/\/www.thegoodwillout.com\/productmail\/email\/stock\/', $('button-email-send-93019'))\"\r\n\t\t class=\"input-text\"\r\n\t\t placeholder=\"Your email address\u2026\"\r\n\t\t size=\"30\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"product_id\"\r\n\t\t value=\"93019\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"type\"\r\n\t\t value=\"email\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"parent_id\"\r\n\t\t value=\"92805\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"uenc\"\r\n\t\t value=\"aHR0cHM6Ly93d3cudGhlZ29vZHdpbGxvdXQuY29tL2FkaWRhcy1jb25zb3J0aXVtLXNuZWFrZXItZXhjaGFuZ2UteC1hbGlmZS14LXN0YXJjb3ctc3Rhbi1zbWl0aC13aGl0ZS1jbTgwMDA,\" \/>\r\n\t<button type=\"button\"\r\n\t\t\tid=\"button-email-send-93019\"\r\n\t\t\tclass=\"strong button btn-cart amcart-ignore\"\r\n\t\t\tonclick=\"send_alert_email('https:\/\/www.thegoodwillout.com\/productmail\/email\/stock\/', this)\"\r\n\t\t\ttitle=\"Submit\">\r\n\t\t<span>Submit<\/span>\r\n\t<\/button>\r\n<\/div>\r\n"},"245":{"is_in_stock":false,"custom_status_icon":"","custom_status":"Out of Stock","product_id":"93020","stockalert":"\r\n<div class=\"alert-stock productmail-block\">\r\n\t<label>\r\n\t\tNotify me, when the product is back in stock\t<\/label>\r\n\t<input type=\"text\"\r\n\t\t name=\"guest_email\"\r\n\t\t id=\"productmail_guest_email-93020\"\r\n\t\t onKeyPress=\"return checkIt(event, 'https:\/\/www.thegoodwillout.com\/productmail\/email\/stock\/', $('button-email-send-93020'))\"\r\n\t\t class=\"input-text\"\r\n\t\t placeholder=\"Your email address\u2026\"\r\n\t\t size=\"30\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"product_id\"\r\n\t\t value=\"93020\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"type\"\r\n\t\t value=\"email\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"parent_id\"\r\n\t\t value=\"92805\" \/>\r\n\t<input type=\"hidden\"\r\n\t\t name=\"uenc\"\r\n\t\t value=\"aHR0cHM6Ly93d3cudGhlZ29vZHdpbGxvdXQuY29tL2FkaWRhcy1jb25zb3J0aXVtLXNuZWFrZXItZXhjaGFuZ2UteC1hbGlmZS14LXN0YXJjb3ctc3Rhbi1zbWl0aC13aGl0ZS1jbTgwMDA,\" \/>\r\n\t<button type=\"button\"\r\n\t\t\tid=\"button-email-send-93020\"\r\n\t\t\tclass=\"strong button btn-cart amcart-ignore\"\r\n\t\t\tonclick=\"send_alert_email('https:\/\/www.thegoodwillout.com\/productmail\/email\/stock\/', this)\"\r\n\t\t\ttitle=\"Submit\">\r\n\t\t<span>Submit<\/span>\r\n\t<\/button>\r\n<\/div>\r\n"}});
}
catch(ex){}
</script>
<div class="configurable-product-option no-display">
<div class="configurable-product-option-wrapper">
<h2>Please select your size</h2>
<div class="drop-select">
<label for="attribute139"></label>
<select name="super_attribute[139]"
id="attribute139"
class="required-entry super-attribute-select">
<option>Choose an Option...</option>
</select>
</div>
</div>
</div>
<script type="text/javascript">
var spConfig = new Product.Config({"attributes":{"139":{"id":"139","code":"eu_size","label":"EU ","options":[{"id":"255","label":"EU 36 2\/3 \/ US 4.5","price":"0","oldPrice":"0","products":[]},{"id":"256","label":"EU 37 1\/3 \/ US 5","price":"0","oldPrice":"0","products":["93005"]},{"id":"365","label":"EU 38 \/ US 5.5","price":"0","oldPrice":"0","products":["93006"]},{"id":"257","label":"EU 38 2\/3 \/ US 6","price":"0","oldPrice":"0","products":["93007"]},{"id":"258","label":"EU 39 1\/3 \/ US 6.5","price":"0","oldPrice":"0","products":["93008"]},{"id":"364","label":"EU 40 \/ US 7","price":"0","oldPrice":"0","products":["93009"]},{"id":"242","label":"EU 40 2\/3 \/ US 7.5","price":"0","oldPrice":"0","products":[]},{"id":"246","label":"EU 41 1\/3 \/ US 8","price":"0","oldPrice":"0","products":[]},{"id":"363","label":"EU 42 \/ US 8.5","price":"0","oldPrice":"0","products":[]},{"id":"248","label":"EU 42 2\/3 \/ US 9","price":"0","oldPrice":"0","products":[]},{"id":"243","label":"EU 43 1\/3 \/ US 9.5","price":"0","oldPrice":"0","products":[]},{"id":"368","label":"EU 44 \/ US 10","price":"0","oldPrice":"0","products":[]},{"id":"244","label":"EU 44 2\/3 US 10.5","price":"0","oldPrice":"0","products":[]},{"id":"247","label":"EU 45 1\/3 \/ US 11","price":"0","oldPrice":"0","products":[]},{"id":"79","label":"EU 46 \/ US 11.5","price":"0","oldPrice":"0","products":[]},{"id":"249","label":"EU 46 2\/3 \/ US 12","price":"0","oldPrice":"0","products":[]},{"id":"245","label":"EU 47 1\/3 \/ US 12.5","price":"0","oldPrice":"0","products":[]}]}},"template":"\u20ac#{price}","basePrice":"149","oldPrice":"149","productId":"92805","chooseText":"Choose an Option...","taxConfig":{"includeTax":true,"showIncludeTax":true,"showBothPrices":false,"defaultTax":19,"currentTax":19,"inclTaxTitle":"Incl. Tax"}});
</script>
<h3>Choose size</h3>
<div class="clearfix " data-attribute="attribute139" >
<div class="attribute-item disabled"
data-value="255">
EU 36 2/3 / US 4.5 </div>
<div class="attribute-item "
data-value="256">
EU 37 1/3 / US 5 </div>
<div class="attribute-item "
data-value="365">
EU 38 / US 5.5 </div>
<div class="attribute-item "
data-value="257">
EU 38 2/3 / US 6 </div>
<div class="attribute-item "
data-value="258">
EU 39 1/3 / US 6.5 </div>
<div class="attribute-item "
data-value="364">
EU 40 / US 7 </div>
<div class="attribute-item disabled"
data-value="242">
EU 40 2/3 / US 7.5 </div>
<div class="attribute-item disabled"
data-value="246">
EU 41 1/3 / US 8 </div>
<div class="attribute-item disabled"
data-value="363">
EU 42 / US 8.5 </div>
<div class="attribute-item disabled"
data-value="248">
EU 42 2/3 / US 9 </div>
<div class="attribute-item disabled"
data-value="243">
EU 43 1/3 / US 9.5 </div>
<div class="attribute-item disabled"
data-value="368">
EU 44 / US 10 </div>
<div class="attribute-item disabled"
data-value="244">
EU 44 2/3 US 10.5 </div>
<div class="attribute-item disabled"
data-value="247">
EU 45 1/3 / US 11 </div>
<div class="attribute-item disabled"
data-value="79">
EU 46 / US 11.5 </div>
<div class="attribute-item disabled"
data-value="249">
EU 46 2/3 / US 12 </div>
<div class="attribute-item disabled"
data-value="245">
EU 47 1/3 / US 12.5 </div>
</div>
<div id="stock-alert-notification">
<span>Desired size not in stock?</span>
</div>
<script type="text/javascript">
//<![CDATA[
var DateOption = Class.create({
getDaysInMonth: function(month, year)
{
var curDate = new Date();
if (!month) {
month = curDate.getMonth();
}
if (2 == month && !year) { // leap year assumption for unknown year
return 29;
}
if (!year) {
year = curDate.getFullYear();
}
return 32 - new Date(year, month - 1, 32).getDate();
},
reloadMonth: function(event)
{
var selectEl = event.findElement();
var idParts = selectEl.id.split("_");
if (idParts.length != 3) {
return false;
}
var optionIdPrefix = idParts[0] + "_" + idParts[1];
var month = parseInt($(optionIdPrefix + "_month").value);
var year = parseInt($(optionIdPrefix + "_year").value);
var dayEl = $(optionIdPrefix + "_day");
var days = this.getDaysInMonth(month, year);
//remove days
for (var i = dayEl.options.length - 1; i >= 0; i--) {
if (dayEl.options[i].value > days) {
dayEl.remove(dayEl.options[i].index);
}
}
// add days
var lastDay = parseInt(dayEl.options[dayEl.options.length-1].value);
for (i = lastDay + 1; i <= days; i++) {
this.addOption(dayEl, i, i);
}
},
addOption: function(select, text, value)
{
var option = document.createElement('OPTION');
option.value = value;
option.text = text;
if (select.options.add) {
select.options.add(option);
} else {
select.appendChild(option);
}
}
});
dateOption = new DateOption();
//]]>
</script>
我拉的完整HTML -
yyyy-mm-dd
答案 0 :(得分:1)
(编辑)的 给定输出,这是带有一些JSON的HTML。您可以使用正则表达式来获取JSON,然后将其解析为本机Python对象。
类似的东西:
import re
import json
json_text = None
lines=result1.text.split('\n')
r = re.compile('new StockStatus\(({.*})\);$')
for l in lines:
m = r.search(l)
if m:
json_text = m.group(1)
break
items = json.loads(json_text).values()
filtered_items = [x['product_id'] for x in items if x.get('is_in_stock') and x.get('custom_status') != 'Out of Stock']
print filtered_items
答案 1 :(得分:0)
使用json.loads
将其转换为对象
import json
all_product_ids = json.loads(jsonString)
sizes_in_stock = []
for size in all_product_ids:
if "Out of Stock" not in all_product_ids[size]["custom_status"]:
size_id = all_product_ids[size]["product_id"]
#size_id = size_id.split("_")[1] # "93147" what to split?
sizes_in_stock.append(size_id)
print sizes_in_stock
# ['93135', '93134', '93132', '93133']