Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/345.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python .split()函数提供索引器:列表索引超出了beautifulsoup的范围_Python_Beautifulsoup - Fatal编程技术网

Python .split()函数提供索引器:列表索引超出了beautifulsoup的范围

Python .split()函数提供索引器:列表索引超出了beautifulsoup的范围,python,beautifulsoup,Python,Beautifulsoup,代码: url='1〕https://steamcommunity.com/market/itemordershistogram?country=CN&language=english¤cy=23&item_nameid=1321474' source=requests.get(url,cookies=cookies,headers=headers,timeout=10) source.encoding='utf-8' 如果(source.ok!=True): 打印(f'\n错误:{

代码:

url='1〕https://steamcommunity.com/market/itemordershistogram?country=CN&language=english¤cy=23&item_nameid=1321474'
source=requests.get(url,cookies=cookies,headers=headers,timeout=10)
source.encoding='utf-8'
如果(source.ok!=True):
打印(f'\n错误:{source.status\u code}\n')
返回0
soup=str(BS(source.text,'lxml'))
印花(汤)
打印(打字(汤))
蒸汽=[]
steam.append(int(soup.split(“'sell_-order_-summary”)[1]。split('for-sale')[0]))#销售数量
印刷(蒸汽)
错误:

url = 'https://steamcommunity.com/market/itemordershistogram?country=CN&language=english&currency=23&item_nameid=1321474'
source = requests.get(url, cookies=cookies, headers=headers, timeout=10)
source.encoding = 'utf-8'
if(source.ok != True):
    print(f'\nError: {source.status_code}\n')
    return 0
soup = str(BS(source.text, 'lxml'))
print(soup)
print(type(soup))
steam = []
steam.append(int(soup.split(""""sell_order_summary":"<span class='\"market_commodity_orders_header_promote\"'>""")[1].split(' for sale')[0])) # Sell Quantity
print(steam)
回溯(最近一次呼叫最后一次):
文件“C:\Users\Andrew\Desktop\ultralight\REQUESTS\u MODULE.py”,第188行,在
打印(请求\u抛光\u蒸汽\u项目('https://steamcommunity.com/market/listings/730/Desert%20Eagle%20%7C%20Blaze%20%28Factory%20New%29'))
文件“C:\Users\Andrew\Desktop\ultralight\REQUESTS\u MODULE.py”,第182行,在request\u buff\u steam\u项中
steam.append(int(soup.split(“'sell_-order_-summary”)[1]。split('for-sale')[0]))#销售数量
索引器:列表索引超出范围
汤:

{“成功”:1,“销售订单”表“

价格数量\u00a5 2225.621\u00a5 2249.901\u00a5 2258.021\u00a5 2274.401\u00a5 2299.792\u00a5 2300或更多”,“销售订单摘要”:“41从\u00a5 2225.62开始销售”,“购买订单”:“PriceQuantity\u00a5 2105.451\u00a5 1949.091\u00a5 1948.992\u00a5 1948.301\u00a5 1946.051\u00a5 1938或以下2510”,“购买订单摘要”:“2516次在\u00a5 2105.45或以下购买的请求”,“最高购买订单”:“210545”,“最低销售订单”:“222562”,“购买订单”:[[2105.45,1,“1次在\u00a5 2105.45或以上购买订单],[1949.09,”2张1949.09或更高价位的订单,[1948.99,4,“4张1948.99或更高价位的订单,[1948.3,5”,“5张1948.30或更高价位的订单,[1946.05,6”,“6张1946.05或更高价位的订单,[1938,8”,“8张1938或更高价位的订单,[1930,9”,“9张1930或更高价位的订单,[1897.65,10,”10份价格为\u00a5 1897.65或更高“],[1885.66,15,”15份价格为\u00a5 1885.66或更高“,[1870.29,16,”16份价格为\u00a5 1870.29或更高“],[1856.45,21,”21份价格为\u00a5 1856.45或更高“,[1826,22,”22份价格为\u00a5 1826或更高“,[1806.07,23,”23份价格为\u00a5 1806.07或更高“,[1800,25,”25个在\u00a5 1800或更高点的购买订单,[1796.16,26],26个在\u00a5 1796.16或更高点的购买订单,[1769.68,27,”27个在\u00a5 1769.68或更高点的购买订单,[1766,28,”28个在\u00a5 1766或更高点的购买订单,[1763.37,29],29个在\u00a5 1763.37或更高点的购买订单,[1754.06,30,“30个在\u00a5 1754.06或更高点的购买订单,[1750.46,31,”31个位于\u00a5 1750.46或更高“],[1740,32,”32个位于\u00a5 1740或更高“],[1734.78,33,”33个位于\u00a5 1734.78或更高“],[1730.41,34,”34个位于\u00a5 1730.41或更高“],[1728.1,35,”35个位于\u00a5 1728.10或更高“,[1721.1,36,”36个位于\u00a5 1721.10或更高“,[1719.55,37,”37、[1715.66,38]、[1712,39]、[1710.81,44]、[1708,45]、[1705,46]、[1705,46]、[1701.08,47]、[1705.55或更高的购买订单、[1715.66,38]、[1712,39]、[1710.81,44]、[1708,45]、[1705,46]、[1705,46]、[1701.08,47、”47个在\u00a5 1701.08或更高点的购买订单“],[1700.99,52,”52个在\u00a5 1700.99或更高点的购买订单“],[1700.13,54,”54个在\u00a5 1700.13或更高点的购买订单“],[1696.45,59,”59个在\u00a5 1696.45或更高点的购买订单“,[1693.09,60,”60个在\u00a5 1693.09或更高点的购买订单“],[1691.85,61,”61个在\u00a5.85或更高点的购买订单“,[1671.38,62,”62份在\u00a5 1671.38或更高点的订单,[1649.56,63],[1635.34,64,”64份在\u00a5 1635.34或更高点的订单,[1610,69,”69份在\u00a5 1610或更高点的订单,[1600,73],73份在\u00a5 1600或更高点的订单,[1599.99,76,”76份在\u00a5 1599.99或更高点的订单,[1595,78,”78个在\u00a5 1595或更高“],[1588,79,”79个在\u00a5 1588或更高“],[1587,80,”80个在\u00a5 1587或更高“],[1585.63,81,”81个在\u00a5 1585.63或更高“],[1579.99,82,”82个在\u00a5 1579.99或更高“],[1578.51,84,”84个在\u00a5 1578.51或更高“,[1577.41,85]购买,”85份价格为\u00a5 1577.41或更高的采购订单、[1571.48,87]、[1532.16,88]、[1528.78,89]、[1508.12,90]、[1500.92]、[92份价格为\u00a5 1532.16或更高的采购订单、[u00a5 1528.78,89]、[1508.12,90]、[u00a5 1508.12或更高的采购订单90]、[1500,92份价格为\u00a5 1500或更高的采购订单、[1499.99,94,”94买入价为\u00a5 1499.99或更高“],[1493.13,97,“97买入价为\u00a5 1493.13或更高“],[1489.31,99,”99买入价为\u00a5 1489.31或更高“],[1470.99100,”100买入价为\u00a5 1470.99或更高“,[1457.65101”,“101买入价为\u00a5 1457.65或更高“],[1437.56102”,“102买入价为\u00a5.1437.56或更高”,[1436.3103]、[1428.5104]、[1427.97106]、[1426.19107]、[1422.09109]、[1422.09109]、[1399.98110]、[1436.3103]、[103A51436.30或更高价位的采购订单、[1428.5104]、[1422.09109]、\U00A51422.09或更高价位的采购订单、[1399.98110,”110份价格为\u00a5 1399.98或更高“],[1395.35111,”111份价格为\u00a5 1395.35或更高“],[1393.22112,”112份价格为\u00a5 1393.22或更高“],[1386.59113,”113份价格为\u00a5 1386.59或更高“],[1364.26114,”114份价格为\u00a5 1364.26或更高“,[1359.34115,”115份价格为\u00a5 1359.34或更高“,[1356.86116,“116份价格为\u00a5 1356.86或更高的采购订单”],[1350.94117,“117份价格为\u00a5 1350.94或更高的采购订单”],[1350.21119,“119份价格为\u00a5 1350.21或更高的采购订单”,[1336.8121,“121份价格为\u00a5 1336.80或更高的采购订单”,[1333.2122,”122份采购订单
Traceback (most recent call last):
  File "C:\Users\Andrew\Desktop\ultralight\REQUESTS_MODULE.py", line 188, in <module>
    print(request_buff_steam_item('https://steamcommunity.com/market/listings/730/Desert%20Eagle%20%7C%20Blaze%20%28Factory%20New%29'))
  File "C:\Users\Andrew\Desktop\ultralight\REQUESTS_MODULE.py", line 182, in request_buff_steam_item
    steam.append(int(soup.split(""""sell_order_summary":"<span class='\"market_commodity_orders_header_promote\"'>""")[1].split(' for sale')[0])) # Sell Quantity
IndexError: list index out of range
<html><body><p>{"success":1,"sell_order_table":"</p><table class='\"market_commodity_orders_table\"'><tr><th align='\"right\"'>Price</th><th align='\"right\"'>Quantity</th></tr><tr><td align='\"right\"' class='\"\"'>\u00a5 2,225.62</td><td align='\"right\"'>1</td></tr><tr><td align='\"right\"' class='\"\"'>\u00a5 2,249.90</td><td align='\"right\"'>1</td></tr><tr><td align='\"right\"' class='\"\"'>\u00a5 2,258.02</td><td align='\"right\"'>1</td></tr><tr><td align='\"right\"' class='\"\"'>\u00a5 2,274.40</td><td align='\"right\"'>1</td></tr><tr><td align='\"right\"' class='\"\"'>\u00a5 2,299.79</td><td align='\"right\"'>2</td></tr><tr><td align='\"right\"' class='\"\"'>\u00a5 2,300 or more</td><td align='\"right\"'>35","sell_order_summary":"<span class='\"market_commodity_orders_header_promote\"'>41 for sale starting at <span class='\"market_commodity_orders_header_promote\"'>\u00a5 2,225.62","buy_order_table":"<table class='\"market_commodity_orders_table\"'><tr><th align='\"right\"'>Price</th><th align='\"right\"'>Quantity</th></tr><tr><td align='\"right\"' class='\"\"'>\u00a5 2,105.45</td><td align='\"right\"'>1</td></tr><tr><td align='\"right\"' class='\"\"'>\u00a5 1,949.09</td><td align='\"right\"'>1</td></tr><tr><td align='\"right\"' class='\"\"'>\u00a5 1,948.99</td><td align='\"right\"'>2</td></tr><tr><td align='\"right\"' class='\"\"'>\u00a5 1,948.30</td><td align='\"right\"'>1</td></tr><tr><td align='\"right\"' class='\"\"'>\u00a5 1,946.05</td><td align='\"right\"'>1</td></tr><tr><td align='\"right\"' class='\"\"'>\u00a5 1,938 or less</td><td align='\"right\"'>2510","buy_order_summary":"<span class='\"market_commodity_orders_header_promote\"'>2516 requests to buy at <span class='\"market_commodity_orders_header_promote\"'>\u00a5 2,105.45 or lower","highest_buy_order":"210545","lowest_sell_order":"222562","buy_order_graph":[[2105.45,1,"1 buy orders at \u00a5 2,105.45 or higher"],[1949.09,2,"2 buy orders at \u00a5 1,949.09 or higher"],[1948.99,4,"4 buy orders at \u00a5 1,948.99 or higher"],[1948.3,5,"5 buy orders at \u00a5 1,948.30 or higher"],[1946.05,6,"6 buy orders at \u00a5 1,946.05 or higher"],[1938,8,"8 buy orders at \u00a5 1,938 or higher"],[1930,9,"9 buy orders at \u00a5 1,930 or higher"],[1897.65,10,"10 buy orders at \u00a5 1,897.65 or higher"],[1885.66,15,"15 buy orders at \u00a5 1,885.66 or higher"],[1870.29,16,"16 buy orders at \u00a5 1,870.29 or higher"],[1856.45,21,"21 buy orders at \u00a5 1,856.45 or higher"],[1826,22,"22 buy orders at \u00a5 1,826 or higher"],[1806.07,23,"23 buy orders at \u00a5 1,806.07 or higher"],[1800,25,"25 buy orders at \u00a5 1,800 or higher"],[1796.16,26,"26 buy orders at \u00a5 1,796.16 or higher"],[1769.68,27,"27 buy orders at \u00a5 1,769.68 or higher"],[1766,28,"28 buy orders at \u00a5 1,766 or higher"],[1763.37,29,"29 buy orders at \u00a5 1,763.37 or higher"],[1754.06,30,"30 buy orders at \u00a5 1,754.06 or higher"],[1750.46,31,"31 buy orders at \u00a5 1,750.46 or higher"],[1740,32,"32 buy orders at \u00a5 1,740 or higher"],[1734.78,33,"33 buy orders at \u00a5 1,734.78 or higher"],[1730.41,34,"34 buy orders at \u00a5 1,730.41 or higher"],[1728.1,35,"35 buy orders at \u00a5 1,728.10 or higher"],[1721.1,36,"36 buy orders at \u00a5 1,721.10 or higher"],[1719.55,37,"37 buy orders at \u00a5 1,719.55 or higher"],[1715.66,38,"38 buy orders at \u00a5 1,715.66 or higher"],[1712,39,"39 buy orders at \u00a5 1,712 or higher"],[1710.81,44,"44 buy orders at \u00a5 1,710.81 or higher"],[1708,45,"45 buy orders at \u00a5 1,708 or higher"],[1705,46,"46 buy orders at \u00a5 1,705 or higher"],[1701.08,47,"47 buy orders at \u00a5 1,701.08 or higher"],[1700.99,52,"52 buy orders at \u00a5 1,700.99 or higher"],[1700.13,54,"54 buy orders at \u00a5 1,700.13 or higher"],[1696.45,59,"59 buy orders at \u00a5 1,696.45 or higher"],[1693.09,60,"60 buy orders at \u00a5 1,693.09 or higher"],[1691.85,61,"61 buy orders at \u00a5 1,691.85 or higher"],[1671.38,62,"62 buy orders at \u00a5 1,671.38 or higher"],[1649.56,63,"63 buy orders at \u00a5 1,649.56 or higher"],[1635.34,64,"64 buy orders at \u00a5 1,635.34 or higher"],[1610,69,"69 buy orders at \u00a5 1,610 or higher"],[1600,73,"73 buy orders at \u00a5 1,600 or higher"],[1599.99,76,"76 buy orders at \u00a5 1,599.99 or higher"],[1595,78,"78 buy orders at \u00a5 1,595 or higher"],[1588,79,"79 buy orders at \u00a5 1,588 or higher"],[1587,80,"80 buy orders at \u00a5 1,587 or higher"],[1585.63,81,"81 buy orders at \u00a5 1,585.63 or higher"],[1579.99,82,"82 buy orders at \u00a5 1,579.99 or higher"],[1578.51,84,"84 buy orders at \u00a5 1,578.51 or higher"],[1577.41,85,"85 buy orders at \u00a5 1,577.41 or higher"],[1571.48,87,"87 buy orders at \u00a5 1,571.48 or higher"],[1532.16,88,"88 buy orders at \u00a5 1,532.16 or higher"],[1528.78,89,"89 buy orders at \u00a5 1,528.78 or higher"],[1508.12,90,"90 buy orders at \u00a5 1,508.12 or higher"],[1500,92,"92 buy orders at \u00a5 1,500 or higher"],[1499.99,94,"94 buy orders at \u00a5 1,499.99 or higher"],[1493.13,97,"97 buy orders at \u00a5 1,493.13 or higher"],[1489.31,99,"99 buy orders at \u00a5 1,489.31 or higher"],[1470.99,100,"100 buy orders at \u00a5 1,470.99 or higher"],[1457.65,101,"101 buy orders at \u00a5 1,457.65 or higher"],[1437.56,102,"102 buy orders at \u00a5 1,437.56 or higher"],[1436.3,103,"103 buy orders at \u00a5 1,436.30 or higher"],[1428.5,104,"104 buy orders at \u00a5 1,428.50 or higher"],[1427.97,106,"106 buy orders at \u00a5 1,427.97 or higher"],[1426.19,107,"107 buy orders at \u00a5 1,426.19 or higher"],[1422.09,109,"109 buy orders at \u00a5 1,422.09 or higher"],[1399.98,110,"110 buy orders at \u00a5 1,399.98 or higher"],[1395.35,111,"111 buy orders at \u00a5 1,395.35 or higher"],[1393.22,112,"112 buy orders at \u00a5 1,393.22 or higher"],[1386.59,113,"113 buy orders at \u00a5 1,386.59 or higher"],[1364.26,114,"114 buy orders at \u00a5 1,364.26 or higher"],[1359.34,115,"115 buy orders at \u00a5 1,359.34 or higher"],[1356.86,116,"116 buy orders at \u00a5 1,356.86 or higher"],[1350.94,117,"117 buy orders at \u00a5 1,350.94 or higher"],[1350.21,119,"119 buy orders at \u00a5 1,350.21 or higher"],[1336.8,121,"121 buy orders at \u00a5 1,336.80 or higher"],[1333.2,122,"122 buy orders at \u00a5 1,333.20 or higher"],[1319.39,123,"123 buy orders at \u00a5 1,319.39 or higher"],[1283.47,124,"124 buy orders at \u00a5 1,283.47 or higher"],[1250,126,"126 buy orders at \u00a5 1,250 or higher"],[1244.41,129,"129 buy orders at \u00a5 1,244.41 or higher"],[1229.44,130,"130 buy orders at \u00a5 1,229.44 or higher"],[1224.59,132,"132 buy orders at \u00a5 1,224.59 or higher"],[1221.5,133,"133 buy orders at \u00a5 1,221.50 or higher"],[1208.76,134,"134 buy orders at \u00a5 1,208.76 or higher"],[1149.88,136,"136 buy orders at \u00a5 1,149.88 or higher"],[1146.1,137,"137 buy orders at \u00a5 1,146.10 or higher"],[1141.96,139,"139 buy orders at \u00a5 1,141.96 or higher"],[1140.38,140,"140 buy orders at \u00a5 1,140.38 or higher"],[1118.1,142,"142 buy orders at \u00a5 1,118.10 or higher"],[1109.24,144,"144 buy orders at \u00a5 1,109.24 or higher"],[1084.71,145,"145 buy orders at \u00a5 1,084.71 or higher"],[1080.86,146,"146 buy orders at \u00a5 1,080.86 or higher"],[1080.38,147,"147 buy orders at \u00a5 1,080.38 or higher"],[1059.39,149,"149 buy orders at \u00a5 1,059.39 or higher"],[1046.1,150,"150 buy orders at \u00a5 1,046.10 or higher"],[1043,151,"151 buy orders at \u00a5 1,043 or higher"],[995.5,153,"153 buy orders at \u00a5 995.50 or higher"],[976.2,154,"154 buy orders at \u00a5 976.20 or higher"],[955.16,156,"156 buy orders at \u00a5 955.16 or higher"],[924.37,158,"158 buy orders at \u00a5 924.37 or higher"]],"sell_order_graph":[[2225.62,1,"1 sell orders at \u00a5 2,225.62 or lower"],[2249.9,2,"2 sell orders at \u00a5 2,249.90 or lower"],[2258.02,3,"3 sell orders at \u00a5 2,258.02 or lower"],[2274.4,4,"4 sell orders at \u00a5 2,274.40 or lower"],[2299.79,6,"6 sell orders at \u00a5 2,299.79 or lower"],[2300,7,"7 sell orders at \u00a5 2,300 or lower"],[2366.15,8,"8 sell orders at \u00a5 2,366.15 or lower"],[2415.3,9,"9 sell orders at \u00a5 2,415.30 or lower"],[2453.09,10,"10 sell orders at \u00a5 2,453.09 or lower"],[2500.95,11,"11 sell orders at \u00a5 2,500.95 or lower"],[2542.34,12,"12 sell orders at \u00a5 2,542.34 or lower"],[2616.55,13,"13 sell orders at \u00a5 2,616.55 or lower"],[2634.71,14,"14 sell orders at \u00a5 2,634.71 or lower"],[2644.65,15,"15 sell orders at \u00a5 2,644.65 or lower"],[2668.65,16,"16 sell orders at \u00a5 2,668.65 or lower"],[2737.03,17,"17 sell orders at \u00a5 2,737.03 or lower"],[2788.12,18,"18 sell orders at \u00a5 2,788.12 or lower"],[2829.77,19,"19 sell orders at \u00a5 2,829.77 or lower"],[2986.32,20,"20 sell orders at \u00a5 2,986.32 or lower"],[3189.03,21,"21 sell orders at \u00a5 3,189.03 or lower"],[3217.31,22,"22 sell orders at \u00a5 3,217.31 or lower"],[3270.69,23,"23 sell orders at \u00a5 3,270.69 or lower"],[3649.33,24,"24 sell orders at \u00a5 3,649.33 or lower"],[3832.89,25,"25 sell orders at \u00a5 3,832.89 or lower"],[3860.38,26,"26 sell orders at \u00a5 3,860.38 or lower"],[4025,27,"27 sell orders at \u00a5 4,025 or lower"],[4088.37,28,"28 sell orders at \u00a5 4,088.37 or lower"]],"graph_max_y":200,"graph_min_x":924.37,"graph_max_x":4088.37,"price_prefix":"\u00a5","price_suffix":""}</span></span></td></tr></table></span></span></td></tr></table></body></html>
steam.append(int(soup.split("""sell_order_summary":"<span class='\\"market_commodity_orders_header_promote\\"'>""")[1].split(' for sale')[0])) # Sell Quantity
import json

json_obj = json.loads(source.text)
soup = BS(json_obj['sell_order_summary'], 'lxml')
steam = []
steam.append(int(soup.find('span').text))