Python如何使用Mechaniz提交表单

2024-09-29 23:31:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在Python中使用Mechanize提交表单。表单显示为

Form name: None
<GET http://www.wunderground.com/cgi-bin/findweather/getForecast application/x-www-form-urlencoded
  <HiddenControl(airportorwmo=query) (readonly)>
  <HiddenControl(historytype=DailyHistory) (readonly)>
  <HiddenControl(backurl=/history/index.html) (readonly)>
  <TextControl(code=)>
  <SelectControl(month=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, *11, 12])>
  <SelectControl(day=[1, 2, *3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31])>
  <SelectControl(year=[*2015, 2014, 2013, 2012, 2011, 2010, 2009, 2008, 2007, 2006, 2005, 2004, 2003, 2002, 2001, 2000, 1999, 1998, 1997, 1996, 1995, 1994, 1993, 1992, 1991, 1990, 1989, 1988, 1987, 1986, 1985, 1984, 1983, 1982, 1981, 1980, 1979, 1978, 1977, 1976, 1975, 1974, 1973, 1972, 1971, 1970, 1969, 1968, 1967, 1966, 1965, 1964, 1963, 1962, 1961, 1960, 1959, 1958, 1957, 1956, 1955, 1954, 1953, 1952, 1951, 1950, 1949, 1948, 1947, 1946, 1945])>
  <SubmitControl(<None>=Submit) (readonly)>>

我们可以看到这里有一个SubmitControl。然后我试着填写这张表格并提交。代码如下所示。在

^{pr2}$

然后我得到了错误

AttributeError: class HTMLForm has no attribute 'sumbit'

Tags: nameformcomnonehttp表单getwww

热门问题